Dependency Injection Style
AOT Compiling Switched to Secret from Development json file Added Kanbn Humanizer HelperCreateNoteFiles.CleanExistingFiles HelperPackageFilesByDate Added SRP Helper Hardcoded File Search and Sort Set Date from Zip Entry
This commit is contained in:
parent
81472165f7
commit
229b508ae1
28
.kanbn/board.css
Normal file
28
.kanbn/board.css
Normal file
@ -0,0 +1,28 @@
|
||||
.kanbn-column-wip .kanbn-column-task-list {
|
||||
border-color: #6929c4;
|
||||
}
|
||||
.kanbn-column-next .kanbn-column-task-list {
|
||||
border-color: #1192e8;
|
||||
}
|
||||
.kanbn-column-wait .kanbn-column-task-list {
|
||||
border-color: #005d5d;
|
||||
}
|
||||
.kanbn-column-later .kanbn-column-task-list {
|
||||
border-color: #9f1853;
|
||||
}
|
||||
.kanbn-column-maybe .kanbn-column-task-list {
|
||||
border-color: #fa4d56;
|
||||
}
|
||||
.kanbn-column-friday .kanbn-column-task-list {
|
||||
border-color: #570408;
|
||||
}
|
||||
.kanbn-column-done .kanbn-column-task-list {
|
||||
border-color: #198038;
|
||||
}
|
||||
.kanbn-task-data-workload {
|
||||
display: none;
|
||||
}
|
||||
.kanbn-task-data-relation {
|
||||
display: block;
|
||||
color: #198038;
|
||||
}
|
29
.kanbn/index.md
Normal file
29
.kanbn/index.md
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
startedColumns:
|
||||
- 'In Progress'
|
||||
completedColumns:
|
||||
- Done
|
||||
dateFormat: mm/dd
|
||||
taskTemplate: '^+^_${overdue ? ''^R'' : ''''}${name}^: ${relations ? (''\n^-^/^g'' + relations.reduce((accumulator, currentValue) => accumulator.task + currentValue.task + '' '', '''')) : ''''}'
|
||||
created: 2023-07-06T21:45:24.551Z
|
||||
updated: 2023-07-07T03:46:47.454Z
|
||||
---
|
||||
|
||||
# File File Helper
|
||||
|
||||
## Backlog
|
||||
|
||||
## Todo
|
||||
|
||||
- [find-orphan-links](tasks/find-orphan-links.md)
|
||||
|
||||
## In Progress
|
||||
|
||||
## Done
|
||||
|
||||
- [break-circular-references](tasks/break-circular-references.md)
|
||||
- [populate-a-collection-of-file-info-front-matter-and-first-indent-of-1](tasks/populate-a-collection-of-file-info-front-matter-and-first-indent-of-1.md)
|
||||
- [use-humanizer-on-title-of-links](tasks/use-humanizer-on-title-of-links.md)
|
||||
- [convert-files-to-slug-name](tasks/convert-files-to-slug-name.md)
|
||||
- [convert-wiki-links-to-markdown-links](tasks/convert-wiki-links-to-markdown-links.md)
|
||||
- [add-update-date-in-front-matter](tasks/add-update-date-in-front-matter.md)
|
12
.kanbn/tasks/add-update-date-in-front-matter.md
Normal file
12
.kanbn/tasks/add-update-date-in-front-matter.md
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
created: 2023-07-08T00:27:35.865Z
|
||||
updated: 2023-07-08T03:13:43.907Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
completed: 2023-07-08T03:13:43.907Z
|
||||
---
|
||||
|
||||
# Add / Update date in Front Matter
|
||||
|
||||
- [ ] Maybe done
|
11
.kanbn/tasks/break-circular-references.md
Normal file
11
.kanbn/tasks/break-circular-references.md
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
created: 2023-07-08T00:31:18.301Z
|
||||
updated: 2023-07-08T03:13:47.959Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
started: 2023-07-08T00:31:22.970Z
|
||||
completed: 2023-07-08T03:13:47.959Z
|
||||
---
|
||||
|
||||
# Break Circular References
|
10
.kanbn/tasks/convert-files-to-slug-name.md
Normal file
10
.kanbn/tasks/convert-files-to-slug-name.md
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
created: 2023-07-08T00:31:48.068Z
|
||||
updated: 2023-07-08T03:13:39.928Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
completed: 2023-07-08T03:13:39.928Z
|
||||
---
|
||||
|
||||
# Convert files to slug name
|
11
.kanbn/tasks/convert-wiki-links-to-markdown-links.md
Normal file
11
.kanbn/tasks/convert-wiki-links-to-markdown-links.md
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
created: 2023-07-08T00:28:50.180Z
|
||||
updated: 2023-07-08T03:14:14.308Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
started: 2023-07-08T02:17:20.346Z
|
||||
completed: 2023-07-08T03:14:14.308Z
|
||||
---
|
||||
|
||||
# Convert Wiki Links to Markdown Links
|
10
.kanbn/tasks/find-orphan-links.md
Normal file
10
.kanbn/tasks/find-orphan-links.md
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
created: 2023-07-08T00:30:27.277Z
|
||||
updated: 2023-07-08T04:49:18.108Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
started: 2023-07-08T04:41:56.433Z
|
||||
---
|
||||
|
||||
# Find orphan links
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
created: 2023-07-08T00:30:00.353Z
|
||||
updated: 2023-07-08T04:08:04.155Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
started: 2023-07-08T02:17:23.556Z
|
||||
completed: 2023-07-08T04:08:04.156Z
|
||||
---
|
||||
|
||||
# Populate a collection of FileInfo, Front Matter and First # indent of 1
|
10
.kanbn/tasks/use-humanizer-on-title-of-links.md
Normal file
10
.kanbn/tasks/use-humanizer-on-title-of-links.md
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
created: 2023-07-08T03:22:14.065Z
|
||||
updated: 2023-07-08T04:08:05.706Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
completed: 2023-07-08T04:08:05.706Z
|
||||
---
|
||||
|
||||
# Use humanizer on title of links
|
3
.prettierignore
Normal file
3
.prettierignore
Normal file
@ -0,0 +1,3 @@
|
||||
/*
|
||||
|
||||
!/.kanbn
|
29
.vscode/launch.json
vendored
29
.vscode/launch.json
vendored
@ -9,14 +9,13 @@
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/bin/Debug/net6.0/win-x64/File-Folder-Helper.dll",
|
||||
"program": "${workspaceFolder}/bin/Debug/net7.0/win-x64/File-Folder-Helper.dll",
|
||||
"args": [
|
||||
"s",
|
||||
"C",
|
||||
"D:/"
|
||||
"\\\\messv02ecc1.ec.local\\EC_EDA\\Staging\\Traces\\HTR-PLC\\R72-PLC\\PollPath"
|
||||
],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"console": "externalTerminal",
|
||||
"console": "integratedTerminal",
|
||||
"stopAtEntry": false
|
||||
},
|
||||
{
|
||||
@ -26,3 +25,25 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
// dotnet build
|
||||
// dotnet run "s" "\\messv02ecc1.ec.local\EC_EDA\Staging\Traces\HTR-PLC\R45-PLC\PollPath"
|
||||
// dotnet run "s" "\\messv02ecc1.ec.local\EC_EDA\Staging\Traces\HTR-PLC\R47-PLC\PollPath"
|
||||
// dotnet run "s" "\\messv02ecc1.ec.local\EC_EDA\Staging\Traces\HTR-PLC\R49-PLC\PollPath"
|
||||
// dotnet run "s" "\\messv02ecc1.ec.local\EC_EDA\Staging\Traces\HTR-PLC\R51-PLC\PollPath"
|
||||
// dotnet run "s" "\\messv02ecc1.ec.local\EC_EDA\Staging\Traces\HTR-PLC\R70-PLC\PollPath"
|
||||
// dotnet run "s" "\\messv02ecc1.ec.local\EC_EDA\Staging\Traces\HTR-PLC\R72-PLC\PollPath"
|
||||
// dotnet run "s" "\\messv02ecc1.ec.local\EC_EDA\Staging\Traces\HTR-PLC\R73-PLC\PollPath"
|
||||
// dotnet run "s" "\\messv02ecc1.ec.local\EC_EDA\Staging\Traces\HTR-PLC\R74-PLC\PollPath"
|
||||
// dotnet run "s" "C:/Users/phares/.nuget/packages"
|
||||
// dotnet run "s" "D:/ProgramData/EC_EAFRepository/nupkg"
|
||||
// dotnet run "s" "D:/Baget/packages"
|
||||
// dotnet run "s" "L:/Baget/packages"
|
||||
// dotnet run "s" "L:/Verdaccio/storage"
|
||||
// dotnet run "s" "\\messdv002.na.infineon.com\Candela\BaGet\packages"
|
||||
// dotnet run "s" "\\messa01ec.ec.local\apps\Metrology\Run Data Repository"
|
||||
// dotnet run "s" "D:/Documents/Obsidian/Infineon/.kanbn"
|
||||
// dotnet run "s" "L:/Git/View-by-Distance-MKLink-Console/.kanbn"
|
||||
// dotnet run "s" "T:/MESAFIBACKLOG/06_SourceCode/MESAFIBACKLOG/Adaptation/.kanbn"
|
||||
// dotnet run "s" "D:/Documents/Projects/EC Documentation - Foam/.kanbn"
|
||||
// dotnet run "s" "D:/Documents/Notes/Infineon"
|
||||
// dotnet run "s" "D:/5-Other-Small/Notes/Infineon/.kanbn"
|
14
.vscode/settings.json
vendored
14
.vscode/settings.json
vendored
@ -1,11 +1,21 @@
|
||||
{
|
||||
"[markdown]": {
|
||||
"editor.wordWrap": "off"
|
||||
},
|
||||
"files.exclude": {
|
||||
"**/.git": false
|
||||
"**/.git": false,
|
||||
"**/node_modules": true
|
||||
},
|
||||
"files.watcherExclude": {
|
||||
"**/node_modules": true
|
||||
},
|
||||
"cSpell.words": [
|
||||
"ASPNETCORE",
|
||||
"endianness",
|
||||
"Infineon",
|
||||
"Kanban",
|
||||
"Phares",
|
||||
"Serilog"
|
||||
"Serilog",
|
||||
"SYSLIB"
|
||||
]
|
||||
}
|
60
.vscode/tasks.json
vendored
60
.vscode/tasks.json
vendored
@ -1,6 +1,47 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "userSecretsInit",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"user-secrets",
|
||||
"-p",
|
||||
"${workspaceFolder}/File-Folder-Helper.csproj",
|
||||
"init"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "userSecretsSet",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"user-secrets",
|
||||
"-p",
|
||||
"${workspaceFolder}/File-Folder-Helper.csproj",
|
||||
"set",
|
||||
"asdf",
|
||||
"123"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "format",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"format",
|
||||
"--report",
|
||||
".vscode",
|
||||
"--verbosity",
|
||||
"detailed",
|
||||
"--severity",
|
||||
"warn"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
@ -36,6 +77,25 @@
|
||||
"${workspaceFolder}/File-Folder-Helper.csproj"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "publishAot",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"publish",
|
||||
"-r",
|
||||
"win-x64",
|
||||
"-c",
|
||||
"Release",
|
||||
"-p:PublishAot=true",
|
||||
"--source",
|
||||
"https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json",
|
||||
"${workspaceFolder}/File-Folder-Helper.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,34 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<UserSecretsId>eb9e8f58-fcb5-45bb-9d4d-54f064c485b1</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="TextCopy" Version="6.1.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="appsettings.Staging.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="appsettings.Development.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="7.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
||||
<PackageReference Include="TextCopy" Version="6.2.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -5,30 +5,89 @@ namespace File_Folder_Helper.Helpers;
|
||||
internal static class HelperCreateNoteFiles
|
||||
{
|
||||
|
||||
private static void CleanExistingFiles(string directory, long ticks)
|
||||
{
|
||||
string check;
|
||||
string[] lines;
|
||||
string checkFile;
|
||||
string? fileDirectory;
|
||||
string checkDirectory;
|
||||
bool circularReference;
|
||||
string fileNameWithoutExtension;
|
||||
char altDrive = directory[0] is 'c' or 'C' ? 'D' : 'C';
|
||||
string[] files = Directory.GetFiles(directory, "*.md", SearchOption.AllDirectories);
|
||||
string match = ",*** *** *** *** *** *** *** *** ***,*** *** *** *** *** *** *** *** ***,*** *** *** *** *** *** *** *** ***,,TODO:,*** *** *** *** *** *** *** *** ***,*** *** *** *** *** *** *** *** ***,,Notes:,*** *** *** *** *** *** *** *** ***,*** *** *** *** *** *** *** *** ***";
|
||||
foreach (string file in files)
|
||||
{
|
||||
lines = File.ReadAllLines(file);
|
||||
if (lines.Length < 1)
|
||||
continue;
|
||||
circularReference = false;
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
if (!lines[i].Contains($"[[{fileNameWithoutExtension}]]"))
|
||||
continue;
|
||||
lines[i] = lines[i].Replace("[[", "__").Replace("]]", "__");
|
||||
if (!circularReference)
|
||||
circularReference = true;
|
||||
}
|
||||
if (circularReference)
|
||||
File.WriteAllLines(file, lines);
|
||||
lines[0] = string.Empty;
|
||||
check = string.Join(',', lines);
|
||||
if (check != match)
|
||||
continue;
|
||||
fileDirectory = Path.GetDirectoryName(file);
|
||||
if (string.IsNullOrEmpty(fileDirectory))
|
||||
continue;
|
||||
checkDirectory = $"{altDrive}:/{ticks}/{fileDirectory[3..]}";
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
checkFile = $"{altDrive}:/{ticks}/{file[3..]}";
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
}
|
||||
_ = HelperDeleteEmptyDirectories.DeleteEmptyDirectories(directory);
|
||||
}
|
||||
|
||||
internal static void CreateNoteFiles(string argsZero)
|
||||
{
|
||||
string file;
|
||||
string directory;
|
||||
string weekOfYear;
|
||||
DateTime dateTime;
|
||||
DateTime nowDateTime = DateTime.Now;
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
CleanExistingFiles(argsZero, ticks);
|
||||
string lastDirectory = string.Empty;
|
||||
DateTime firstEmail = new(2019, 3, 8);
|
||||
DateTime startDateTime = DateTime.Now.AddDays(1);
|
||||
Calendar calendar = new CultureInfo("en-US").Calendar;
|
||||
const string line = "*** *** *** *** *** *** *** *** ***";
|
||||
double totalDays = new TimeSpan(nowDateTime.AddDays(1000).Ticks - firstEmail.Ticks).TotalDays;
|
||||
double totalDays = new TimeSpan(DateTime.Now.AddDays(1000).Ticks - startDateTime.Ticks).TotalDays;
|
||||
int days = (int)Math.Ceiling(totalDays);
|
||||
for (int i = 0; i < days; i++)
|
||||
{
|
||||
dateTime = firstEmail.AddDays(i);
|
||||
dateTime = startDateTime.AddDays(i);
|
||||
weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
directory = Path.Combine(argsZero, nowDateTime.Ticks.ToString(), dateTime.ToString("yyyy"), $"Week_{weekOfYear}");
|
||||
directory = Path.Combine(argsZero, ticks.ToString(), dateTime.ToString("yyyy"), $"Week_{weekOfYear}");
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
file = string.Concat(Path.Combine(directory, $"{dateTime:yyyy-MM-dd}.txt"));
|
||||
file = string.Concat(Path.Combine(directory, $"{dateTime:yyyy-MM-dd}.md"));
|
||||
if (File.Exists(file))
|
||||
continue;
|
||||
File.WriteAllLines(file, new string[] { dateTime.ToString("dddd"), line, line, line, "", "TODO:", line, line, "", "Notes:", line, line });
|
||||
File.WriteAllLines(file, new string[]
|
||||
{
|
||||
"---",
|
||||
"type: daily-note",
|
||||
$"created: {dateTime:yyyy-MM-dd}",
|
||||
"---",
|
||||
string.Empty,
|
||||
$"# {dateTime:yyyy-MM-dd dddd}",
|
||||
string.Empty,
|
||||
"```bash",
|
||||
string.Empty,
|
||||
"```",
|
||||
});
|
||||
if (directory != lastDirectory)
|
||||
{
|
||||
Directory.SetCreationTime(directory, dateTime);
|
||||
|
82
Helpers/HelperHardcodedFileSearchAndSort.cs
Normal file
82
Helpers/HelperHardcodedFileSearchAndSort.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Globalization;
|
||||
|
||||
namespace File_Folder_Helper.Helpers;
|
||||
|
||||
internal static class HelperHardcodedFileSearchAndSort
|
||||
{
|
||||
|
||||
internal static void HardcodedFileSearchAndSort(ILogger log, string sourceDirectory, SearchOption searchOption = SearchOption.TopDirectoryOnly)
|
||||
{
|
||||
bool check;
|
||||
string lines;
|
||||
string checkFile;
|
||||
string? directory;
|
||||
FileInfo fileInfo;
|
||||
string weekOfYear;
|
||||
string checkDirectory;
|
||||
CultureInfo cultureInfo = new("en-US");
|
||||
Calendar calendar = cultureInfo.Calendar;
|
||||
string[] hardcodedValues = new string[]
|
||||
{
|
||||
"BIORAD2",
|
||||
"BIORAD3",
|
||||
"BIORAD4",
|
||||
"BIORAD5",
|
||||
"CDE2",
|
||||
"CDE3",
|
||||
"CDE4",
|
||||
"CDE5",
|
||||
"CDE6",
|
||||
"HGCV1",
|
||||
"HGCV2",
|
||||
"HGCV3",
|
||||
"TENCOR1",
|
||||
"TENCOR2",
|
||||
"TENCOR3",
|
||||
"SP101",
|
||||
"SPV01",
|
||||
"SRP",
|
||||
"Bio-Rad"
|
||||
};
|
||||
string[] files = Directory.GetFiles(sourceDirectory, "*", searchOption);
|
||||
foreach (string file in files)
|
||||
{
|
||||
directory = Path.GetDirectoryName(file);
|
||||
if (string.IsNullOrEmpty(directory))
|
||||
continue;
|
||||
check = false;
|
||||
fileInfo = new(file);
|
||||
weekOfYear = calendar.GetWeekOfYear(fileInfo.LastWriteTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
if (check)
|
||||
break;
|
||||
lines = i switch
|
||||
{
|
||||
1 => fileInfo.Name,
|
||||
2 => File.ReadAllText(file),
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
foreach (string hardcodedValue in hardcodedValues)
|
||||
{
|
||||
if (!lines.Contains(hardcodedValue))
|
||||
continue;
|
||||
checkDirectory = Path.Combine(directory, $"{fileInfo.LastWriteTime:yyyy}_Week_{weekOfYear}", fileInfo.LastWriteTime.ToString("yyyy-MM-dd"), hardcodedValue);
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
checkFile = Path.Combine(checkDirectory, Path.GetFileName(file));
|
||||
if (File.Exists(checkFile) || !File.Exists(file))
|
||||
continue;
|
||||
try
|
||||
{ File.Move(file, checkFile); }
|
||||
catch (Exception) { }
|
||||
check = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.LogInformation(sourceDirectory);
|
||||
}
|
||||
|
||||
}
|
82
Helpers/HelperKanbanMetadata.cs
Normal file
82
Helpers/HelperKanbanMetadata.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace File_Folder_Helper.Helpers;
|
||||
|
||||
internal static class HelperKanbanMetadata
|
||||
{
|
||||
|
||||
private static List<(int, int, string, FileInfo)> GetCollectionFromIndex(string sourceDirectory, string[] lines)
|
||||
{
|
||||
List<(int, int, string, FileInfo)> results = new();
|
||||
string line;
|
||||
FileInfo fileInfo;
|
||||
string[] segments;
|
||||
int groupCount = 0;
|
||||
string? group = null;
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
line = lines[i];
|
||||
if (line.Length < 4)
|
||||
continue;
|
||||
if (line[..3] == "## ")
|
||||
{
|
||||
group = line[3..];
|
||||
groupCount += 1;
|
||||
continue;
|
||||
}
|
||||
if (group is null || line[..3] != "- [" || line[^1] != ')')
|
||||
continue;
|
||||
segments = line.Split("](");
|
||||
if (segments.Length != 2)
|
||||
continue;
|
||||
fileInfo = new(Path.Combine(sourceDirectory, segments[1][..^1]));
|
||||
if (!fileInfo.Exists)
|
||||
continue;
|
||||
results.Add((groupCount, i, group, fileInfo));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static void SetMetadata(ILogger log, Models.AppSettings appSettings, string sourceDirectory)
|
||||
{
|
||||
string statusLine;
|
||||
List<string> lines;
|
||||
LineNumber lineNumber;
|
||||
if (log is null)
|
||||
throw new NullReferenceException();
|
||||
string fullPath = Path.GetFullPath(sourceDirectory);
|
||||
if (!Directory.Exists(fullPath))
|
||||
_ = Directory.CreateDirectory(fullPath);
|
||||
List<(MarkdownFile, string[])> collection;
|
||||
collection = HelperMarkdown.GetCollection(appSettings, HelperMarkdown.GetFiles(appSettings, fullPath));
|
||||
string indexFile = Path.Combine(fullPath, "index.md");
|
||||
if (File.Exists(indexFile))
|
||||
{
|
||||
string[] indexFileLines = File.ReadAllLines(indexFile);
|
||||
List<(int, int, string, FileInfo)> collectionFromIndex = GetCollectionFromIndex(sourceDirectory, indexFileLines);
|
||||
foreach ((int groupCount, int itemLineNumber, string group, FileInfo fileInfo) in collectionFromIndex)
|
||||
{
|
||||
if (itemLineNumber == 0)
|
||||
throw new NotSupportedException();
|
||||
(lines, lineNumber) = HelperMarkdown.GetStatusAndMetaEndLineNumbers(fileInfo);
|
||||
if (!lines.Any())
|
||||
continue;
|
||||
statusLine = $"status: \"{groupCount}-{group}\"";
|
||||
indexFileLines[itemLineNumber] = $"{fileInfo.LastWriteTime.Ticks}~~~{indexFileLines[itemLineNumber]}";
|
||||
if (lineNumber.MetaEnd is null)
|
||||
throw new NotSupportedException($"{nameof(SetMetadata)} must be executed first!");
|
||||
if (lineNumber.Status is null)
|
||||
lines.Insert(lineNumber.MetaEnd.Value, statusLine);
|
||||
else
|
||||
{
|
||||
if (lines[lineNumber.Status.Value] == statusLine)
|
||||
continue;
|
||||
lines[lineNumber.Status.Value] = statusLine;
|
||||
}
|
||||
File.WriteAllLines(fileInfo.FullName, lines);
|
||||
}
|
||||
File.WriteAllLines(indexFile, indexFileLines);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
618
Helpers/HelperMarkdown.cs
Normal file
618
Helpers/HelperMarkdown.cs
Normal file
@ -0,0 +1,618 @@
|
||||
using Humanizer;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace File_Folder_Helper.Helpers;
|
||||
|
||||
internal static partial class HelperMarkdown
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Determines a text file's encoding by analyzing its byte order mark (BOM).
|
||||
/// Defaults to ASCII when detection of the text file's endianness fails.
|
||||
/// </summary>
|
||||
/// <param name="filename">The text file to analyze.</param>
|
||||
/// <returns>The detected encoding.</returns>
|
||||
internal static Encoding? GetEncoding(string filename)
|
||||
{
|
||||
Encoding? result;
|
||||
byte[] bom = new byte[4];
|
||||
using FileStream file = new(filename, FileMode.Open, FileAccess.Read);
|
||||
_ = file.Read(bom, 0, 4);
|
||||
if (bom[0] == 0x2b && bom[1] == 0x2f && bom[2] == 0x76)
|
||||
#pragma warning disable SYSLIB0001
|
||||
result = Encoding.UTF7;
|
||||
#pragma warning restore SYSLIB0001
|
||||
if (bom[0] == 0xef && bom[1] == 0xbb && bom[2] == 0xbf)
|
||||
result = Encoding.UTF8;
|
||||
if (bom[0] == 0xff && bom[1] == 0xfe && bom[2] == 0 && bom[3] == 0)
|
||||
result = Encoding.UTF32; //UTF-32LE
|
||||
if (bom[0] == 0xff && bom[1] == 0xfe)
|
||||
result = Encoding.Unicode; //UTF-16LE
|
||||
if (bom[0] == 0xfe && bom[1] == 0xff)
|
||||
result = Encoding.BigEndianUnicode; //UTF-16BE
|
||||
if (bom[0] == 0 && bom[1] == 0 && bom[2] == 0xfe && bom[3] == 0xff)
|
||||
result = new UTF32Encoding(true, true); //UTF-32BE
|
||||
else
|
||||
result = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string[] GetFiles(Models.AppSettings appSettings, string directory)
|
||||
{
|
||||
string[] files = Directory.GetFiles(directory, "*.md", SearchOption.AllDirectories).
|
||||
Where(l => !appSettings.Exclude.Any(m => l.Contains(m))).ToArray();
|
||||
return files;
|
||||
}
|
||||
|
||||
private static (string type, string h1) GetTypeAndH1(Models.AppSettings appSettings, string h1, List<string> lines, LineNumber lineNumber)
|
||||
{
|
||||
string type = lineNumber.Type is null ? appSettings.DefaultNoteType : lines[lineNumber.Type.Value].Replace("type: ", string.Empty);
|
||||
string h1FromFile = lineNumber.H1 is null ? h1 : lines[lineNumber.H1.Value][2..];
|
||||
return (type, h1FromFile);
|
||||
}
|
||||
|
||||
internal static (List<string>, LineNumber) GetStatusAndMetaEndLineNumbers(FileInfo fileInfo)
|
||||
{
|
||||
string line;
|
||||
int? h1LineNumber = null;
|
||||
int? typeLineNumber = null;
|
||||
int? statusLineNumber = null;
|
||||
int? createdLineNumber = null;
|
||||
int? updatedLineNumber = null;
|
||||
int? metaEndLineNumber = null;
|
||||
Encoding? encoding = GetEncoding(fileInfo.FullName) ?? Encoding.Default;
|
||||
string[] lines = File.ReadAllLines(fileInfo.FullName, encoding);
|
||||
for (int i = 1; i < lines.Length; i++)
|
||||
{
|
||||
line = lines[i];
|
||||
if (line.Length < 3)
|
||||
continue;
|
||||
if (line[..3] == "---")
|
||||
{
|
||||
metaEndLineNumber = i;
|
||||
continue;
|
||||
}
|
||||
if (line.Length > 6 && line[..6] == "type: ")
|
||||
{
|
||||
typeLineNumber = i;
|
||||
continue;
|
||||
}
|
||||
if (line.Length > 8 && line[..8] == "status: ")
|
||||
{
|
||||
statusLineNumber = i;
|
||||
continue;
|
||||
}
|
||||
if (line.Length > 9 && line[..9] == "created: ")
|
||||
{
|
||||
createdLineNumber = i;
|
||||
continue;
|
||||
}
|
||||
if (line.Length > 9 && line[..9] == "updated: ")
|
||||
{
|
||||
updatedLineNumber = i;
|
||||
continue;
|
||||
}
|
||||
if (h1LineNumber is null && line.Length > 2 && line[..2] == "# ")
|
||||
{
|
||||
h1LineNumber = i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
LineNumber lineNumber = new(createdLineNumber,
|
||||
h1LineNumber,
|
||||
metaEndLineNumber,
|
||||
statusLineNumber,
|
||||
typeLineNumber,
|
||||
updatedLineNumber);
|
||||
return (lines.ToList(), lineNumber);
|
||||
}
|
||||
|
||||
internal static List<(MarkdownFile, string[])> GetCollection(Models.AppSettings appSettings, string[] files)
|
||||
{
|
||||
List<(MarkdownFile, string[])> results = new();
|
||||
string h1;
|
||||
string type;
|
||||
FileInfo fileInfo;
|
||||
List<string> lines;
|
||||
LineNumber lineNumber;
|
||||
MarkdownFile markdownFile;
|
||||
string fileNameWithoutExtension;
|
||||
foreach (string file in files)
|
||||
{
|
||||
fileInfo = new(file);
|
||||
if (fileInfo.DirectoryName is null)
|
||||
continue;
|
||||
(lines, lineNumber) = GetStatusAndMetaEndLineNumbers(fileInfo);
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
|
||||
h1 = fileNameWithoutExtension.ToLower().Hyphenate();
|
||||
if (lines.Any())
|
||||
(type, h1) = GetTypeAndH1(appSettings, h1, lines, lineNumber);
|
||||
else
|
||||
{
|
||||
type = "note";
|
||||
File.WriteAllLines(file, new string[] { "---", $"type: {type}", "---", string.Empty, $"# {h1}" });
|
||||
lines = File.ReadAllLines(file).ToList();
|
||||
}
|
||||
markdownFile = new(file, fileInfo.DirectoryName, fileInfo.Name, fileNameWithoutExtension, fileInfo.Extension, fileInfo.CreationTime, fileInfo.LastWriteTime, lineNumber, type, h1);
|
||||
results.Add(new(markdownFile, lines.ToArray()));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static bool SetFrontMatterAndH1(Models.AppSettings appSettings, List<(MarkdownFile, string[])> collection)
|
||||
{
|
||||
bool result = false;
|
||||
string h1Line;
|
||||
string typeLine;
|
||||
string createdLine;
|
||||
string updatedLine;
|
||||
DateTime creationDateTime;
|
||||
string createdLineCompare;
|
||||
string updatedLineCompare;
|
||||
List<string> results = new();
|
||||
foreach ((MarkdownFile markdownFile, string[] lines) in collection)
|
||||
{
|
||||
if (markdownFile.FileName == "board.md")
|
||||
continue;
|
||||
if (!lines.Any())
|
||||
continue;
|
||||
results.Clear();
|
||||
results.AddRange(lines);
|
||||
creationDateTime = markdownFile.CreationDateTime > markdownFile.LastWriteDateTime ? markdownFile.LastWriteDateTime : markdownFile.CreationDateTime;
|
||||
typeLine = $"type: {appSettings.DefaultNoteType}";
|
||||
h1Line = $"# {markdownFile.FileNameWithoutExtension}";
|
||||
createdLineCompare = $"created: {creationDateTime.ToUniversalTime():yyyy-MM-dd}";
|
||||
createdLine = $"created: {creationDateTime.ToUniversalTime():yyyy-MM-ddTHH:mm:ss.fffZ}";
|
||||
updatedLineCompare = $"updated: {markdownFile.LastWriteDateTime.ToUniversalTime():yyyy-MM-dd}";
|
||||
updatedLine = $"updated: {markdownFile.LastWriteDateTime.ToUniversalTime():yyyy-MM-ddTHH:mm:ss.fffZ}";
|
||||
if (markdownFile.LineNumber.MetaEnd is null)
|
||||
{
|
||||
if (markdownFile.LineNumber.H1 is null)
|
||||
{
|
||||
results.Insert(0, string.Empty);
|
||||
results.Insert(0, h1Line);
|
||||
results.Insert(0, string.Empty);
|
||||
}
|
||||
results.Insert(0, "---");
|
||||
results.Insert(0, updatedLine);
|
||||
results.Insert(0, createdLine);
|
||||
results.Insert(0, typeLine);
|
||||
results.Insert(0, "---");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (markdownFile.LineNumber.H1 is null)
|
||||
{
|
||||
results.Insert(markdownFile.LineNumber.MetaEnd.Value + 1, string.Empty);
|
||||
results.Insert(markdownFile.LineNumber.MetaEnd.Value + 1, h1Line);
|
||||
results.Insert(markdownFile.LineNumber.MetaEnd.Value + 1, string.Empty);
|
||||
}
|
||||
if (markdownFile.LineNumber.Type is null)
|
||||
results.Insert(markdownFile.LineNumber.MetaEnd.Value, typeLine);
|
||||
if (markdownFile.LineNumber.Updated is null)
|
||||
results.Insert(markdownFile.LineNumber.MetaEnd.Value, updatedLine);
|
||||
else
|
||||
{
|
||||
if (results[markdownFile.LineNumber.Updated.Value].Contains('$'))
|
||||
continue;
|
||||
if (results[markdownFile.LineNumber.Updated.Value][..updatedLineCompare.Length] == updatedLineCompare)
|
||||
continue;
|
||||
results[markdownFile.LineNumber.Updated.Value] = updatedLine;
|
||||
}
|
||||
if (markdownFile.LineNumber.Created is null)
|
||||
results.Insert(markdownFile.LineNumber.MetaEnd.Value, createdLine);
|
||||
else if (results[markdownFile.LineNumber.Created.Value][..createdLineCompare.Length] != createdLineCompare)
|
||||
results[markdownFile.LineNumber.Created.Value] = createdLine;
|
||||
}
|
||||
if (!result)
|
||||
result = true;
|
||||
File.WriteAllLines(markdownFile.File, results);
|
||||
File.SetLastWriteTime(markdownFile.File, markdownFile.LastWriteDateTime);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static bool CircularReference(List<(MarkdownFile, string[])> collection)
|
||||
{
|
||||
bool result = false;
|
||||
string line;
|
||||
string check;
|
||||
bool circularReference;
|
||||
foreach ((MarkdownFile markdownFile, string[] lines) in collection)
|
||||
{
|
||||
if (lines.Length < 1)
|
||||
continue;
|
||||
circularReference = false;
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
check = $"[[{markdownFile.FileNameWithoutExtension}]]";
|
||||
if (!lines[i].Contains(check))
|
||||
continue;
|
||||
line = lines[i].Replace(check, $"~~{markdownFile.FileName}~~");
|
||||
if (lines[i] == line)
|
||||
continue;
|
||||
lines[i] = line;
|
||||
if (!circularReference)
|
||||
circularReference = true;
|
||||
}
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
check = $"{markdownFile.FileNameWithoutExtension}|{markdownFile.FileNameWithoutExtension}]]";
|
||||
if (!lines[i].Contains(check))
|
||||
continue;
|
||||
line = lines[i].Replace(check, $"~~{markdownFile.FileName}~~");
|
||||
if (lines[i] == line)
|
||||
continue;
|
||||
lines[i] = line;
|
||||
if (!circularReference)
|
||||
circularReference = true;
|
||||
}
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
check = $"[{markdownFile.FileNameWithoutExtension}]({markdownFile.FileName})";
|
||||
if (!lines[i].Contains(check))
|
||||
continue;
|
||||
line = lines[i].Replace(check, $"~~{markdownFile.FileName}~~");
|
||||
if (lines[i] == line)
|
||||
continue;
|
||||
lines[i] = line;
|
||||
if (!circularReference)
|
||||
circularReference = true;
|
||||
}
|
||||
if (circularReference)
|
||||
{
|
||||
if (!result)
|
||||
result = true;
|
||||
File.WriteAllLines(markdownFile.File, lines);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static bool FindReplace(List<(MarkdownFile, string[])> collection)
|
||||
{
|
||||
bool result = false;
|
||||
bool found;
|
||||
string line;
|
||||
string check;
|
||||
foreach ((MarkdownFile markdownFile, string[] lines) in collection)
|
||||
{
|
||||
if (lines.Length < 1)
|
||||
continue;
|
||||
found = false;
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
check = $"[[K-A/";
|
||||
if (!lines[i].Contains(check))
|
||||
continue;
|
||||
line = lines[i].Replace(check, "[[.kanbn/Archive/");
|
||||
if (lines[i] == line)
|
||||
continue;
|
||||
lines[i] = line;
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
check = $"[[K-T/";
|
||||
if (!lines[i].Contains(check))
|
||||
continue;
|
||||
line = lines[i].Replace(check, "[[.kanbn/Tasks/");
|
||||
if (lines[i] == line)
|
||||
continue;
|
||||
lines[i] = line;
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
if (!result)
|
||||
result = true;
|
||||
File.WriteAllLines(markdownFile.File, lines);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Dictionary<string, List<MarkdownFile>> GetKeyValuePairs(List<(MarkdownFile MarkdownFile, string[] Lines)> collection)
|
||||
{
|
||||
Dictionary<string, List<MarkdownFile>> results = new();
|
||||
List<MarkdownFile>? markdownFiles;
|
||||
foreach ((MarkdownFile markdownFile, _) in collection)
|
||||
{
|
||||
if (!results.TryGetValue(markdownFile.FileNameWithoutExtension, out markdownFiles))
|
||||
{
|
||||
results.Add(markdownFile.FileNameWithoutExtension, new());
|
||||
if (!results.TryGetValue(markdownFile.FileNameWithoutExtension, out markdownFiles))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
markdownFiles.Add(markdownFile);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private static (string?, string?) GetRelativePath(Dictionary<string, List<MarkdownFile>> keyValuePairs, MarkdownFile markdownFile, string file)
|
||||
{
|
||||
string? result;
|
||||
string? match;
|
||||
string? title;
|
||||
List<MarkdownFile>? markdownFiles;
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
|
||||
if (keyValuePairs.TryGetValue(fileNameWithoutExtension, out markdownFiles))
|
||||
{
|
||||
if (markdownFiles.Count != 1)
|
||||
(match, title) = (null, null);
|
||||
else
|
||||
(match, title) = (markdownFiles.First().File, markdownFiles.First().H1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!keyValuePairs.TryGetValue(fileNameWithoutExtension.ToLower(), out markdownFiles))
|
||||
(match, title) = (null, null);
|
||||
else
|
||||
{
|
||||
if (markdownFiles.Count != 1)
|
||||
(match, title) = (null, null);
|
||||
else
|
||||
(match, title) = (markdownFiles.First().File, markdownFiles.First().H1);
|
||||
}
|
||||
}
|
||||
if (match is null)
|
||||
{
|
||||
List<string> files = new();
|
||||
List<string> fileNames = new();
|
||||
foreach (KeyValuePair<string, List<MarkdownFile>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
foreach (MarkdownFile keyValue in keyValuePair.Value)
|
||||
{
|
||||
files.Add(keyValue.File);
|
||||
fileNames.Add(keyValue.FileNameWithoutExtension);
|
||||
}
|
||||
}
|
||||
string[] matches = fileNames.Where(l => l.Length == fileNameWithoutExtension.Length && l.Contains(fileNameWithoutExtension, StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
if (matches.Length == 1)
|
||||
match = matches.First();
|
||||
else
|
||||
{
|
||||
string checkName = fileNameWithoutExtension.ToLower().Replace("%20", "-").Replace(' ', '-');
|
||||
matches = fileNames.Where(l => l.Length == checkName.Length && l.Contains(checkName, StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
if (matches.Length == 1)
|
||||
match = matches.First();
|
||||
else
|
||||
{
|
||||
if (!matches.Any())
|
||||
match = null;
|
||||
else
|
||||
{
|
||||
checkName = matches.First();
|
||||
matches = files.Where(l => l.Contains(checkName, StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
if (matches.Length == 1)
|
||||
match = matches.First();
|
||||
else
|
||||
{
|
||||
checkName = $"{checkName}{markdownFile.Extension}";
|
||||
matches = files.Where(l => l.EndsWith(checkName, StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
if (matches.Length == 1)
|
||||
match = matches.First();
|
||||
else
|
||||
{
|
||||
checkName = $"\\{checkName}";
|
||||
matches = files.Where(l => l.EndsWith(checkName, StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
if (matches.Length == 1)
|
||||
match = matches.First();
|
||||
else
|
||||
match = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result = match is null ? null : Path.GetRelativePath(markdownFile.Directory, Path.GetFullPath(match));
|
||||
return (result, title);
|
||||
}
|
||||
|
||||
internal static bool ConvertToRelativePath(List<(MarkdownFile MarkdownFile, string[] Lines)> collection)
|
||||
{
|
||||
bool result = false;
|
||||
bool write;
|
||||
string line;
|
||||
string after;
|
||||
string before;
|
||||
string? title;
|
||||
string[] segmentsA;
|
||||
string[] segmentsB;
|
||||
string[] segmentsC;
|
||||
string? relativePath;
|
||||
Dictionary<string, List<MarkdownFile>> keyValuePairs = GetKeyValuePairs(collection);
|
||||
foreach ((MarkdownFile markdownFile, string[] lines) in collection)
|
||||
{
|
||||
if (lines.Length < 1)
|
||||
continue;
|
||||
write = false;
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
segmentsA = lines[i].Split("]]");
|
||||
if (segmentsA.Length is not 2 or 3)
|
||||
continue;
|
||||
segmentsB = segmentsA.First().Split("[[");
|
||||
if (segmentsB.Length is not 2 or 3)
|
||||
continue;
|
||||
after = segmentsA.Last();
|
||||
before = segmentsB.First();
|
||||
segmentsC = segmentsB.Last().Split('|');
|
||||
(relativePath, title) = GetRelativePath(keyValuePairs, markdownFile, segmentsC.First());
|
||||
if (relativePath is null)
|
||||
continue;
|
||||
if (title is null)
|
||||
{
|
||||
title = segmentsC.Last().Humanize(LetterCasing.Title);
|
||||
if (title.Length != segmentsC.Last().Length)
|
||||
title = segmentsC.Last();
|
||||
}
|
||||
line = $"{before}[{title}]({relativePath.Replace('\\', '/')}){after}";
|
||||
if (lines[i] == line)
|
||||
continue;
|
||||
lines[i] = line;
|
||||
if (!write)
|
||||
write = true;
|
||||
}
|
||||
if (write)
|
||||
{
|
||||
if (!result)
|
||||
result = true;
|
||||
File.WriteAllLines(markdownFile.File, lines);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static bool ConvertFileToSlugName(List<(MarkdownFile MarkdownFile, string[] Lines)> collection)
|
||||
{
|
||||
bool result = false;
|
||||
bool write;
|
||||
string h1;
|
||||
string file;
|
||||
string line;
|
||||
string? title;
|
||||
string h1Check;
|
||||
string fileName;
|
||||
string checkName;
|
||||
string? directory;
|
||||
string[] segmentsA;
|
||||
string[] segmentsB;
|
||||
string[] segmentsC;
|
||||
string checkFileName;
|
||||
string segmentsALast;
|
||||
string segmentsBFirst;
|
||||
string relativeDirectory;
|
||||
string formattedRelativeDirectory;
|
||||
Dictionary<string, List<MarkdownFile>> keyValuePairs = GetKeyValuePairs(collection);
|
||||
foreach ((MarkdownFile markdownFile, string[] lines) in collection)
|
||||
{
|
||||
if (markdownFile.FileNameWithoutExtension == "index")
|
||||
continue;
|
||||
if (!File.Exists(markdownFile.File))
|
||||
continue;
|
||||
write = false;
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
segmentsA = lines[i].Split("](");
|
||||
if (segmentsA.Length != 2)
|
||||
continue;
|
||||
segmentsALast = segmentsA.Last();
|
||||
if (segmentsALast.StartsWith("http:") || segmentsALast.StartsWith("https:") || segmentsALast.StartsWith("rdp:") || segmentsALast.StartsWith("onenote:"))
|
||||
continue;
|
||||
segmentsB = segmentsALast.Split(")");
|
||||
if (segmentsB.Length != 2)
|
||||
continue;
|
||||
segmentsBFirst = segmentsB.First();
|
||||
file = Path.GetFullPath(Path.Combine(markdownFile.Directory, segmentsBFirst));
|
||||
fileName = Path.GetFileName(file);
|
||||
directory = Path.GetDirectoryName(file);
|
||||
if (string.IsNullOrEmpty(directory))
|
||||
continue;
|
||||
relativeDirectory = segmentsBFirst[..^fileName.Length];
|
||||
formattedRelativeDirectory = relativeDirectory.Replace(" ", "%20");
|
||||
checkFileName = fileName.ToLower().Replace("%20", "-").Replace(' ', '-');
|
||||
checkName = Path.Combine(directory, checkFileName);
|
||||
segmentsC = segmentsA.First().Split('[');
|
||||
(_, title) = GetRelativePath(keyValuePairs, markdownFile, file);
|
||||
if (title is null)
|
||||
{
|
||||
title = segmentsC.Last().Humanize(LetterCasing.Title);
|
||||
if (title.Length != segmentsC.Last().Length)
|
||||
title = segmentsC.Last();
|
||||
}
|
||||
line = $"{segmentsC.First()}[{title}]({Path.Combine(formattedRelativeDirectory, checkFileName)}){segmentsB.Last()}";
|
||||
if (lines[i] == line)
|
||||
continue;
|
||||
if (fileName.Contains(' ') || fileName.Contains("%20"))
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
continue;
|
||||
if (File.Exists(checkName))
|
||||
continue;
|
||||
File.Move(file, checkName);
|
||||
}
|
||||
else if (fileName != fileName.ToLower())
|
||||
{
|
||||
if (file != checkName)
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
continue;
|
||||
File.Move(file, checkName);
|
||||
}
|
||||
}
|
||||
lines[i] = line;
|
||||
if (!write)
|
||||
write = true;
|
||||
}
|
||||
if (write)
|
||||
{
|
||||
if (!result)
|
||||
result = true;
|
||||
File.WriteAllLines(markdownFile.File, lines);
|
||||
}
|
||||
}
|
||||
if (!result)
|
||||
{
|
||||
foreach ((MarkdownFile markdownFile, string[] lines) in collection)
|
||||
{
|
||||
if (markdownFile.LineNumber.H1 is not null)
|
||||
{
|
||||
h1 = lines[markdownFile.LineNumber.H1.Value];
|
||||
if (h1.Length > 2)
|
||||
{
|
||||
h1Check = $"# {h1[2..].Humanize(LetterCasing.Title)}";
|
||||
if (h1Check.Length == h1.Length && h1Check != h1)
|
||||
{
|
||||
lines[markdownFile.LineNumber.H1.Value] = h1Check;
|
||||
if (!result)
|
||||
result = true;
|
||||
File.WriteAllLines(markdownFile.File, lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkFileName = markdownFile.FileName.ToLower().Replace("%20", "-").Replace(' ', '-');
|
||||
if (checkFileName == markdownFile.FileName)
|
||||
continue;
|
||||
if (!File.Exists(markdownFile.File))
|
||||
continue;
|
||||
checkName = Path.Combine(markdownFile.Directory, checkFileName);
|
||||
if (checkName == markdownFile.File)
|
||||
continue;
|
||||
if (!result)
|
||||
result = true;
|
||||
File.Move(markdownFile.File, checkName);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static void MarkdownWikiLinkVerification(Models.AppSettings appSettings, string argsZero)
|
||||
{
|
||||
string fullPath = Path.GetFullPath(argsZero);
|
||||
List<(MarkdownFile MarkdownFile, string[] Lines)> collection;
|
||||
collection = GetCollection(appSettings, GetFiles(appSettings, fullPath));
|
||||
if (SetFrontMatterAndH1(appSettings, collection))
|
||||
collection = GetCollection(appSettings, GetFiles(appSettings, fullPath));
|
||||
if (CircularReference(collection))
|
||||
collection = GetCollection(appSettings, GetFiles(appSettings, fullPath));
|
||||
if (FindReplace(collection))
|
||||
collection = GetCollection(appSettings, GetFiles(appSettings, fullPath));
|
||||
if (ConvertToRelativePath(collection))
|
||||
collection = GetCollection(appSettings, GetFiles(appSettings, fullPath));
|
||||
if (ConvertFileToSlugName(collection))
|
||||
collection = GetCollection(appSettings, GetFiles(appSettings, fullPath));
|
||||
string directory = Path.Combine(Environment.CurrentDirectory, ".vscode");
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
||||
string json = JsonSerializer.Serialize(collection.Select(l => l.MarkdownFile), jsonSerializerOptions);
|
||||
File.WriteAllText($"{DateTime.Now.Ticks}.json", json);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
84
Helpers/HelperPackageFilesByDate.cs
Normal file
84
Helpers/HelperPackageFilesByDate.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace File_Folder_Helper.Helpers;
|
||||
|
||||
internal static class HelperPackageFilesByDate
|
||||
{
|
||||
|
||||
public record PackageJson(
|
||||
[property: JsonPropertyName("name")] string Name,
|
||||
[property: JsonPropertyName("time")] Dictionary<string, DateTime> Times,
|
||||
[property: JsonPropertyName("_rev")] string Rev,
|
||||
[property: JsonPropertyName("_id")] string Id
|
||||
);
|
||||
|
||||
internal static void SetDateFromJsonEntry(ILogger log, string sourceDirectory, SearchOption searchOption = SearchOption.AllDirectories)
|
||||
{
|
||||
string json;
|
||||
DateTime dateTime;
|
||||
FileInfo fileInfo;
|
||||
string[] segments;
|
||||
string[] tgzFiles;
|
||||
PackageJson? packageJson;
|
||||
string[] packageJsonFiles;
|
||||
string? packageJsonDirectory;
|
||||
string fileNameWithoutExtension;
|
||||
string packageJsonDirectoryName;
|
||||
List<DateTime> dateTimes = new();
|
||||
if (log is null)
|
||||
throw new NullReferenceException();
|
||||
if (!Directory.Exists(sourceDirectory))
|
||||
_ = Directory.CreateDirectory(sourceDirectory);
|
||||
for (int i = 1; i < 2; i++)
|
||||
{
|
||||
packageJsonFiles = Directory.GetFiles(sourceDirectory, "package.json", searchOption);
|
||||
foreach (string packageJsonFile in packageJsonFiles)
|
||||
{
|
||||
packageJsonDirectory = Path.GetDirectoryName(packageJsonFile);
|
||||
if (string.IsNullOrEmpty(packageJsonDirectory))
|
||||
continue;
|
||||
json = File.ReadAllText(packageJsonFile);
|
||||
packageJson = JsonSerializer.Deserialize<PackageJson>(json);
|
||||
if (packageJson is null || !packageJson.Times.Any())
|
||||
continue;
|
||||
packageJsonDirectoryName = Path.GetFileName(packageJsonDirectory);
|
||||
tgzFiles = Directory.GetFiles(packageJsonDirectory, "*.tgz", SearchOption.TopDirectoryOnly);
|
||||
foreach (string tgzFile in tgzFiles)
|
||||
{
|
||||
dateTimes.Clear();
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(tgzFile);
|
||||
segments = fileNameWithoutExtension.Split('-');
|
||||
foreach (string segment in segments)
|
||||
{
|
||||
if (!packageJson.Times.TryGetValue(segment, out dateTime))
|
||||
continue;
|
||||
dateTimes.Add(dateTime);
|
||||
fileInfo = new(tgzFile);
|
||||
if (fileInfo.LastWriteTime != dateTime)
|
||||
File.SetLastWriteTime(fileInfo.FullName, dateTime);
|
||||
}
|
||||
if (!dateTimes.Any())
|
||||
{
|
||||
if (fileNameWithoutExtension.Length + 1 < packageJsonDirectoryName.Length)
|
||||
continue;
|
||||
if (!packageJson.Times.TryGetValue(fileNameWithoutExtension[(packageJsonDirectoryName.Length + 1)..], out dateTime))
|
||||
continue;
|
||||
dateTimes.Add(dateTime);
|
||||
fileInfo = new(tgzFile);
|
||||
if (fileInfo.LastWriteTime != dateTime)
|
||||
File.SetLastWriteTime(fileInfo.FullName, dateTime);
|
||||
}
|
||||
}
|
||||
if (!dateTimes.Any())
|
||||
continue;
|
||||
dateTime = dateTimes.Max();
|
||||
fileInfo = new(packageJsonFile);
|
||||
if (fileInfo.LastWriteTime != dateTime)
|
||||
File.SetLastWriteTime(fileInfo.FullName, dateTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
using Serilog;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace File_Folder_Helper.Helpers;
|
||||
|
||||
@ -9,14 +9,14 @@ internal static class HelperRenameToOldMoveDeleteOldMerge
|
||||
{
|
||||
string checkDirectory = argsZero[0..^1];
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
log.Information(string.Concat("<", checkDirectory, "> doesn't exist!"));
|
||||
log.LogInformation(string.Concat("<", checkDirectory, "> doesn't exist!"));
|
||||
else
|
||||
{
|
||||
string renameFile;
|
||||
string destinationFile;
|
||||
List<string> deleteFiles = new();
|
||||
string[] moveFiles = Directory.GetFiles(argsZero, "*", SearchOption.TopDirectoryOnly);
|
||||
log.Information(string.Concat("<", moveFiles.Length, "> to move"));
|
||||
log.LogInformation(string.Concat("<", moveFiles.Length, "> to move"));
|
||||
foreach (string moveFile in moveFiles)
|
||||
{
|
||||
destinationFile = string.Concat(checkDirectory, moveFile[argsZero.Length..]);
|
||||
@ -30,7 +30,7 @@ internal static class HelperRenameToOldMoveDeleteOldMerge
|
||||
deleteFiles.Add(renameFile);
|
||||
}
|
||||
}
|
||||
log.Information(string.Concat("<", deleteFiles.Count, "> to delete"));
|
||||
log.LogInformation(string.Concat("<", deleteFiles.Count, "> to delete"));
|
||||
foreach (string deleteFile in deleteFiles)
|
||||
{
|
||||
for (short i = 0; i < short.MaxValue; i++)
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Serilog;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text;
|
||||
|
||||
namespace File_Folder_Helper.Helpers;
|
||||
@ -48,9 +48,9 @@ internal static class HelperSaveOrCopyContents
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
log.Information("D) Directory, F) File or B) Both?");
|
||||
log.LogInformation("D) Directory, F) File or B) Both?");
|
||||
ConsoleKey dfb = Console.ReadKey().Key;
|
||||
log.Information(string.Empty);
|
||||
log.LogInformation(string.Empty);
|
||||
if (dfb is not ConsoleKey.D and not ConsoleKey.F and not ConsoleKey.B)
|
||||
throw new Exception("Not valid");
|
||||
else
|
||||
@ -160,25 +160,25 @@ internal static class HelperSaveOrCopyContents
|
||||
throw new Exception();
|
||||
}
|
||||
TimeSpan timeSpan = new(DateTime.Now.Ticks - now);
|
||||
log.Information(string.Concat(timeSpan.TotalSeconds, " TotalSeconds"));
|
||||
log.LogInformation(string.Concat(timeSpan.TotalSeconds, " TotalSeconds"));
|
||||
if (alongSideTopDirectoryOnly)
|
||||
{
|
||||
File.WriteAllText(filePathAndName, data.ToString());
|
||||
log.Information("Data written");
|
||||
log.LogInformation("Data written");
|
||||
}
|
||||
else if (clipboardTopDirectoryOnly)
|
||||
{
|
||||
TextCopy.ClipboardService.SetText(data.ToString());
|
||||
log.Information("Data stored in clipboard");
|
||||
log.LogInformation("Data stored in clipboard");
|
||||
}
|
||||
else if (alongSideAllDirectories)
|
||||
{
|
||||
File.AppendAllText(filePathAndName, "Done");
|
||||
log.Information("Data written");
|
||||
log.LogInformation("Data written");
|
||||
}
|
||||
else
|
||||
throw new Exception();
|
||||
log.Information("Press any key to close");
|
||||
log.LogInformation("Press any key to close");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Serilog;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Globalization;
|
||||
using System.IO.Compression;
|
||||
using System.Text.RegularExpressions;
|
||||
@ -12,12 +12,15 @@ internal static class HelperZipFilesByDate
|
||||
{
|
||||
string key;
|
||||
bool addFile;
|
||||
string? zipPath;
|
||||
string fileName;
|
||||
string[] segments;
|
||||
string[] subFiles;
|
||||
string weekOfYear;
|
||||
FileInfo fileInfo;
|
||||
string zipDirectory;
|
||||
DateTime creationTime;
|
||||
string? directoryName;
|
||||
DateTime lastWriteTime;
|
||||
DateTime nowDateTime = DateTime.Now;
|
||||
Regex regex = new("[a-zA-Z0-9]{1,}");
|
||||
@ -46,7 +49,10 @@ internal static class HelperZipFilesByDate
|
||||
foreach (string topDirectory in topDirectories)
|
||||
{
|
||||
keyValuePairs.Clear();
|
||||
directoryName = Path.GetDirectoryName(topDirectory);
|
||||
subFiles = Directory.GetFiles(topDirectory, "*", searchOption);
|
||||
zipPath = string.IsNullOrEmpty(directoryName) ? null : Path.Combine(directoryName, "ZipPath");
|
||||
zipDirectory = zipPath is not null && Directory.Exists(zipPath) ? zipPath : topDirectory;
|
||||
foreach (string subFile in subFiles)
|
||||
{
|
||||
addFile = false;
|
||||
@ -98,12 +104,12 @@ internal static class HelperZipFilesByDate
|
||||
}
|
||||
foreach (KeyValuePair<string, List<string>> element in keyValuePairs)
|
||||
{
|
||||
key = Path.Combine(topDirectory, $"{element.Key}.zip");
|
||||
key = Path.Combine(zipDirectory, $"{element.Key}.zip");
|
||||
if (File.Exists(key))
|
||||
{
|
||||
for (short i = 101; i < short.MaxValue; i++)
|
||||
{
|
||||
key = Path.Combine(topDirectory, $"{element.Key}_{i}.zip");
|
||||
key = Path.Combine(zipDirectory, $"{element.Key}_{i}.zip");
|
||||
if (!File.Exists(key))
|
||||
break;
|
||||
}
|
||||
@ -114,18 +120,24 @@ internal static class HelperZipFilesByDate
|
||||
_ = zip.CreateEntryFromFile(file, Path.GetFileName(file));
|
||||
File.Delete(file);
|
||||
}
|
||||
if (zipPath is not null && Directory.Exists(zipPath) && !string.IsNullOrEmpty(directoryName))
|
||||
{
|
||||
try
|
||||
{ Directory.SetLastWriteTime(directoryName, DateTime.Now); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
subFiles = Directory.GetFiles(topDirectory, "*.zip", SearchOption.TopDirectoryOnly);
|
||||
}
|
||||
subFiles = Directory.GetFiles(zipDirectory, "*.zip", SearchOption.TopDirectoryOnly);
|
||||
foreach (string subFile in subFiles)
|
||||
{
|
||||
fileName = Path.GetFileNameWithoutExtension(subFile);
|
||||
segments = fileName.Split('_');
|
||||
if (segments.Length > 2)
|
||||
fileName = string.Concat(segments[0], '_', segments[1], '_', segments[2]);
|
||||
if (weeks.ContainsKey(fileName))
|
||||
if (weeks.TryGetValue(fileName, out DateTime value))
|
||||
{
|
||||
try
|
||||
{ File.SetLastWriteTime(subFile, weeks[fileName]); }
|
||||
{ File.SetLastWriteTime(subFile, value); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
@ -135,7 +147,93 @@ internal static class HelperZipFilesByDate
|
||||
{ _ = HelperDeleteEmptyDirectories.DeleteEmptyDirectories(topDirectory); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
log.Information(topDirectory);
|
||||
log.LogInformation(topDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetDateFromZipEntry(ILogger log, string sourceDirectory, SearchOption searchOption = SearchOption.AllDirectories)
|
||||
{
|
||||
string[] files;
|
||||
string keyFile;
|
||||
string keyFileB;
|
||||
string keyFileC;
|
||||
string checkFile;
|
||||
FileInfo fileInfo;
|
||||
string[] zipFiles;
|
||||
string searchPattern;
|
||||
string? zipDirectory;
|
||||
DateTimeOffset? dateTimeOffset;
|
||||
if (!Directory.Exists(sourceDirectory))
|
||||
_ = Directory.CreateDirectory(sourceDirectory);
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
(searchPattern, keyFile, keyFileB, keyFileC) = i switch
|
||||
{
|
||||
1 => ("*.nupkg", ".nuspec", "icon", "readme"),
|
||||
2 => ("*.vsix", ".vsixmanifest", string.Empty, string.Empty),
|
||||
_ => throw new NotSupportedException()
|
||||
};
|
||||
zipFiles = Directory.GetFiles(sourceDirectory, searchPattern, searchOption);
|
||||
foreach (string zipFile in zipFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
dateTimeOffset = null;
|
||||
fileInfo = new(zipFile);
|
||||
using ZipArchive zip = ZipFile.Open(zipFile, ZipArchiveMode.Read);
|
||||
foreach (ZipArchiveEntry zipArchiveEntry in zip.Entries)
|
||||
{
|
||||
if (!zipArchiveEntry.Name.EndsWith(keyFile))
|
||||
continue;
|
||||
dateTimeOffset = zipArchiveEntry.LastWriteTime;
|
||||
break;
|
||||
}
|
||||
zipDirectory = Path.GetDirectoryName(zipFile);
|
||||
if (dateTimeOffset is null || zipDirectory is null)
|
||||
continue;
|
||||
if (fileInfo.LastWriteTime != dateTimeOffset.Value.LocalDateTime)
|
||||
File.SetLastWriteTime(fileInfo.FullName, dateTimeOffset.Value.LocalDateTime);
|
||||
files = Directory.GetFiles(zipDirectory, $"*{keyFile}", SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
fileInfo = new(file);
|
||||
if (fileInfo.LastWriteTime != dateTimeOffset.Value.LocalDateTime)
|
||||
File.SetLastWriteTime(fileInfo.FullName, dateTimeOffset.Value.LocalDateTime);
|
||||
}
|
||||
if (string.IsNullOrEmpty(keyFileB))
|
||||
continue;
|
||||
files = Directory.GetFiles(zipDirectory, keyFileB, SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
fileInfo = new(file);
|
||||
if (fileInfo.LastWriteTime != dateTimeOffset.Value.LocalDateTime)
|
||||
File.SetLastWriteTime(fileInfo.FullName, dateTimeOffset.Value.LocalDateTime);
|
||||
}
|
||||
if (string.IsNullOrEmpty(keyFileC))
|
||||
continue;
|
||||
files = Directory.GetFiles(zipDirectory, keyFileC, SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
fileInfo = new(file);
|
||||
if (fileInfo.LastWriteTime != dateTimeOffset.Value.LocalDateTime)
|
||||
File.SetLastWriteTime(fileInfo.FullName, dateTimeOffset.Value.LocalDateTime);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
log.LogInformation($"<{zipFile}> is invalid!");
|
||||
checkFile = string.Concat(zipFile, ".err");
|
||||
for (int e = 0; e < short.MaxValue; e++)
|
||||
{
|
||||
if (!File.Exists(checkFile))
|
||||
break;
|
||||
checkFile = string.Concat(checkFile, e);
|
||||
}
|
||||
try
|
||||
{ File.Move(zipFile, checkFile); }
|
||||
catch (Exception) { log.LogInformation($"<{zipFile}> couldn't be moved!"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
8
Helpers/LineNumber.cs
Normal file
8
Helpers/LineNumber.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace File_Folder_Helper.Helpers;
|
||||
|
||||
public record LineNumber(int? Created,
|
||||
int? H1,
|
||||
int? MetaEnd,
|
||||
int? Status,
|
||||
int? Type,
|
||||
int? Updated);
|
12
Helpers/MarkdownFile.cs
Normal file
12
Helpers/MarkdownFile.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace File_Folder_Helper.Helpers;
|
||||
|
||||
public record MarkdownFile(string File,
|
||||
string Directory,
|
||||
string FileName,
|
||||
string FileNameWithoutExtension,
|
||||
string Extension,
|
||||
DateTime CreationDateTime,
|
||||
DateTime LastWriteDateTime,
|
||||
LineNumber LineNumber,
|
||||
string Type,
|
||||
string H1);
|
138
Jenkinsfile
vendored
138
Jenkinsfile
vendored
@ -1,138 +0,0 @@
|
||||
#!/usr/bin/env groovy
|
||||
/* groovylint-disable CompileStatic, ConsecutiveStringConcatenation, DuplicateNumberLiteral, DuplicateStringLiteral, LineLength, NestedBlockDepth, NoDef, VariableTypeRequired */
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String _DDrive = 'D:/'
|
||||
@Field String _AssemblyName = '...'
|
||||
@Field String _NetVersion = 'net6.0'
|
||||
@Field String _GitCommitSeven = '...'
|
||||
@Field String _GitName = 'File-Folder-Helper'
|
||||
@Field String _WorkingDirectoryName = 'IFXApps'
|
||||
@Field String _AgentStaging = 'mestsa07ec-ecmeseaf'
|
||||
@Field String _AgentProduction = 'messa08ec-ecmeseaf'
|
||||
@Field String _DDriveNet = "${_DDrive}${_NetVersion}"
|
||||
@Field String _AgentDevelopment = 'mestsa003-meseafsvc'
|
||||
@Field String _Company = 'Infineon Technologies Americas Corp.'
|
||||
@Field String _ProgramFilesDotnet = 'C:/program files/dotnet/dotnet.exe'
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
label env.JENKINS_ENVIRONMENT == 'Development' ? _AgentDevelopment : env.JENKINS_ENVIRONMENT == 'Staging' ? _AgentStaging : env.JENKINS_ENVIRONMENT == 'Production' ? _AgentProduction : 'Else'
|
||||
}
|
||||
parameters {
|
||||
string(name: 'GIT_SERVER', defaultValue: env.JENKINS_ENVIRONMENT == 'Development' ? 'mestsa003.infineon.com' : 'mestsa07ec.ec.local', description: 'git server')
|
||||
}
|
||||
stages {
|
||||
// stage('Git') {
|
||||
// steps {
|
||||
// bat(returnStatus: true, script: 'git init')
|
||||
// bat(returnStatus: true, script: 'git remote add origin \\\\' + params.GIT_SERVER + '\\Git\\' + _GitName + '.git')
|
||||
// bat(returnStatus: true, script: 'git pull origin master')
|
||||
// }
|
||||
// }
|
||||
stage('Setup') {
|
||||
steps {
|
||||
script {
|
||||
_AssemblyName = "${env.JOB_NAME}"
|
||||
// _GitCommitSeven = '1234567'
|
||||
_GitCommitSeven = env.GIT_COMMIT.substring(0, 7)
|
||||
def files = findFiles(glob: '*.csproj')
|
||||
if (files.length != 1) {
|
||||
error("Build failed because couldn't find a *.csproj file")
|
||||
}
|
||||
echo """
|
||||
${files[0].name}
|
||||
${files[0].path}
|
||||
${files[0].directory}
|
||||
${files[0].length}
|
||||
${files[0].lastModified}
|
||||
"""
|
||||
_AssemblyName = files[0].name.split('[.]csproj')[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Info') {
|
||||
steps {
|
||||
// echo "GIT_URL_N - ${env.GIT_URL_N}"
|
||||
// echo "BRANCH_NAME ${env.BRANCH_NAME}"
|
||||
// echo "DEPLOY_VERSION ${env.DEPLOY_VERSION}"
|
||||
// echo "GIT_AUTHOR_NAME ${env.GIT_AUTHOR_NAME}"
|
||||
// echo "GIT_LOCAL_BRANCH ${env.GIT_LOCAL_BRANCH}"
|
||||
// echo "GIT_COMMITTER_EMAIL ${env.GIT_COMMITTER_EMAIL}"
|
||||
// echo "GIT_PREVIOUS_COMMIT ${env.GIT_PREVIOUS_COMMIT}"
|
||||
// echo "GIT_PREVIOUS_SUCCESSFUL_COMMIT ${env.GIT_PREVIOUS_SUCCESSFUL_COMMIT}"
|
||||
echo "_AssemblyName ${_AssemblyName}" // ...
|
||||
echo "BUILD_NUMBER ${env.BUILD_NUMBER}" // 11
|
||||
echo "GIT_BRANCH ${env.GIT_BRANCH}" // origin/master
|
||||
echo "GIT_COMMIT ${env.GIT_COMMIT}" // 73b814069f2cf0173a62a8228815a9bc9ba93c41
|
||||
echo "GIT_SERVER ${params.GIT_SERVER}" // ...
|
||||
echo "GIT_URL ${env.GIT_URL}" // D:\ProgramData\Git\....git
|
||||
echo "JENKINS_ENVIRONMENT ${env.JENKINS_ENVIRONMENT}" // 11
|
||||
echo "JENKINS_URL ${env.JENKINS_URL}" // http://localhost:8080/
|
||||
echo "JOB_NAME ${env.JOB_NAME}" // ...
|
||||
echo "WORKSPACE ${env.WORKSPACE}" // D:\.jenkins\_\...
|
||||
}
|
||||
}
|
||||
// stage('Restore') {
|
||||
// steps {
|
||||
// bat(returnStatus: true, script: 'dotnet --info')
|
||||
// }
|
||||
// }
|
||||
stage('Safe storage of app secrets') {
|
||||
steps {
|
||||
bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' +
|
||||
'user-secrets init')
|
||||
bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' +
|
||||
'user-secrets set "Company" "' + _Company + '"')
|
||||
bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' +
|
||||
'user-secrets set "BuildNumber" "' + env.BUILD_NUMBER + '"')
|
||||
bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' +
|
||||
'user-secrets set "GitCommitSeven" "' + _GitCommitSeven + '"')
|
||||
bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' +
|
||||
'user-secrets set "WorkingDirectoryName" "' + _WorkingDirectoryName + '"')
|
||||
}
|
||||
}
|
||||
stage('Core Build') {
|
||||
steps {
|
||||
echo "Build number is ${currentBuild.number}"
|
||||
bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' +
|
||||
'build --runtime win-x64 --self-contained --verbosity quiet')
|
||||
}
|
||||
}
|
||||
stage('Commit Id') {
|
||||
steps {
|
||||
writeFile(file: 'bin/Debug/' + _NetVersion + "/win-x64/${env.GIT_COMMIT}-${env.BUILD_NUMBER}.txt", text: "${env.GIT_URL}")
|
||||
}
|
||||
}
|
||||
stage('Package') {
|
||||
steps {
|
||||
fileOperations([fileZipOperation(folderPath: 'bin/Debug/' + _NetVersion + '/win-x64', outputFolderPath: "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}-Debug")])
|
||||
fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*", renameFiles: false, sourceCaptureExpression: '', targetLocation: "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}-Debug", targetNameExpression: '')])
|
||||
}
|
||||
}
|
||||
stage('Publish') {
|
||||
steps {
|
||||
bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' +
|
||||
'publish --configuration Release --runtime win-x64 --verbosity quiet ' +
|
||||
"--self-contained true --p:Version=6.0.202-${_GitCommitSeven}-${env.BUILD_NUMBER} -o " +
|
||||
'"' + "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}" + '"')
|
||||
}
|
||||
}
|
||||
// stage('Force Fail') {
|
||||
// steps {
|
||||
// error("Build failed because of this and that..")
|
||||
// }
|
||||
// }
|
||||
}
|
||||
post {
|
||||
always {
|
||||
dir('bin') {
|
||||
deleteDir()
|
||||
}
|
||||
dir('obj') {
|
||||
deleteDir()
|
||||
}
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +1,13 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace File_Folder_Helper.Models;
|
||||
|
||||
public class AppSettings
|
||||
public record AppSettings(string Company,
|
||||
string DefaultNoteType,
|
||||
string[] Exclude,
|
||||
string WorkingDirectoryName)
|
||||
{
|
||||
|
||||
protected string _Company;
|
||||
protected string _WorkingDirectoryName;
|
||||
public string Company => _Company;
|
||||
public string WorkingDirectoryName => _WorkingDirectoryName;
|
||||
|
||||
// public AppSettings()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string company, string workingDirectoryName)
|
||||
{
|
||||
_Company = company;
|
||||
_WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace File_Folder_Helper.Models.Binder;
|
||||
@ -6,14 +6,10 @@ namespace File_Folder_Helper.Models.Binder;
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
[Display(Name = "Company"), Required] public string Company { get; set; }
|
||||
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
||||
|
||||
public AppSettings()
|
||||
{
|
||||
Company = string.Empty;
|
||||
WorkingDirectoryName = string.Empty;
|
||||
}
|
||||
public string? Company { get; set; }
|
||||
public string? DefaultNoteType { get; set; }
|
||||
public string[]? Exclude { get; set; }
|
||||
public string? WorkingDirectoryName { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
@ -21,4 +17,32 @@ public class AppSettings
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
if (appSettings?.Company is null)
|
||||
throw new NullReferenceException(nameof(appSettings.Company));
|
||||
if (appSettings?.DefaultNoteType is null)
|
||||
throw new NullReferenceException(nameof(appSettings.DefaultNoteType));
|
||||
if (appSettings?.Exclude is null)
|
||||
throw new NullReferenceException(nameof(appSettings.Exclude));
|
||||
if (appSettings?.WorkingDirectoryName is null)
|
||||
throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
||||
result = new(
|
||||
appSettings.Company,
|
||||
appSettings.DefaultNoteType,
|
||||
appSettings.Exclude,
|
||||
appSettings.WorkingDirectoryName
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||
result = Get(appSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace File_Folder_Helper.Models.Stateless;
|
||||
|
||||
public abstract class AppSettings
|
||||
{
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings? result;
|
||||
Binder.AppSettings appSettings = configurationRoot.Get<Binder.AppSettings>();
|
||||
string json = JsonSerializer.Serialize(appSettings, new JsonSerializerOptions() { WriteIndented = true });
|
||||
result = JsonSerializer.Deserialize<Models.AppSettings>(json);
|
||||
if (result is null)
|
||||
throw new Exception(json);
|
||||
if (string.IsNullOrEmpty(result.Company))
|
||||
throw new Exception(json);
|
||||
string jsonThis = result.ToString();
|
||||
if (jsonThis != json)
|
||||
throw new Exception(json);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,167 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Phares.Shared.Models;
|
||||
|
||||
public class IsEnvironment
|
||||
{
|
||||
|
||||
public enum Name
|
||||
{
|
||||
LinuxDevelopment,
|
||||
LinuxProduction,
|
||||
LinuxStaging,
|
||||
OSXDevelopment,
|
||||
OSXProduction,
|
||||
OSXStaging,
|
||||
WindowsDevelopment,
|
||||
WindowsProduction,
|
||||
WindowsStaging
|
||||
}
|
||||
|
||||
public bool DebuggerWasAttachedDuringConstructor { get; private set; }
|
||||
public bool Development { get; private set; }
|
||||
public bool Linux { get; private set; }
|
||||
public bool OSX { get; private set; }
|
||||
public bool Production { get; private set; }
|
||||
public bool Staging { get; private set; }
|
||||
public bool Windows { get; private set; }
|
||||
public string Profile { get; private set; }
|
||||
public string AppSettingsFileName { get; private set; }
|
||||
public string? ASPNetCoreEnvironment { get; private set; }
|
||||
|
||||
public IsEnvironment(string testCategory)
|
||||
{
|
||||
if (testCategory.EndsWith(".json"))
|
||||
{
|
||||
Production = testCategory == "appsettings.json";
|
||||
Staging = testCategory.EndsWith(nameof(Staging));
|
||||
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
Development = testCategory.EndsWith(nameof(Development));
|
||||
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
|
||||
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
}
|
||||
else
|
||||
{
|
||||
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
|
||||
OSX = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(OSX));
|
||||
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
Linux = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Linux));
|
||||
Staging = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Staging));
|
||||
Windows = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Windows));
|
||||
Production = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Production));
|
||||
Development = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Development));
|
||||
}
|
||||
Profile = GetProfile();
|
||||
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
|
||||
}
|
||||
|
||||
public IsEnvironment(bool isDevelopment, bool isStaging, bool isProduction)
|
||||
{
|
||||
Staging = isStaging;
|
||||
Production = isProduction;
|
||||
Development = isDevelopment;
|
||||
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
|
||||
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
Profile = GetProfile();
|
||||
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
|
||||
}
|
||||
|
||||
public IsEnvironment(int? processesCount, bool nullASPNetCoreEnvironmentIsDevelopment, bool nullASPNetCoreEnvironmentIsProduction)
|
||||
{
|
||||
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
|
||||
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
if (nullASPNetCoreEnvironmentIsDevelopment && nullASPNetCoreEnvironmentIsProduction)
|
||||
throw new Exception();
|
||||
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsProduction)
|
||||
Production = true;
|
||||
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsDevelopment)
|
||||
Development = true;
|
||||
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && !nullASPNetCoreEnvironmentIsDevelopment && !nullASPNetCoreEnvironmentIsProduction)
|
||||
throw new Exception();
|
||||
else
|
||||
{
|
||||
Staging = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Staging));
|
||||
Production = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Production));
|
||||
Development = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Development));
|
||||
}
|
||||
Profile = GetProfile();
|
||||
AppSettingsFileName = GetAppSettingsFileName(processesCount);
|
||||
}
|
||||
|
||||
private string GetProfile()
|
||||
{
|
||||
string result;
|
||||
if (Windows && Production)
|
||||
result = nameof(Production);
|
||||
else if (Windows && Staging)
|
||||
result = nameof(Staging);
|
||||
else if (Windows && Development)
|
||||
result = nameof(Development);
|
||||
else if (Linux && Production)
|
||||
result = nameof(Name.LinuxProduction);
|
||||
else if (Linux && Staging)
|
||||
result = nameof(Name.LinuxStaging);
|
||||
else if (Linux && Development)
|
||||
result = nameof(Name.LinuxDevelopment);
|
||||
else if (OSX && Production)
|
||||
result = nameof(Name.OSXProduction);
|
||||
else if (OSX && Staging)
|
||||
result = nameof(Name.OSXStaging);
|
||||
else if (OSX && Development)
|
||||
result = nameof(Name.OSXDevelopment);
|
||||
else
|
||||
throw new Exception();
|
||||
return result;
|
||||
}
|
||||
|
||||
private string GetAppSettingsFileName(int? processesCount)
|
||||
{
|
||||
string result;
|
||||
if (Production)
|
||||
{
|
||||
if (processesCount is null)
|
||||
result = "appsettings.json";
|
||||
else
|
||||
result = $"appsettings.{processesCount}.json";
|
||||
}
|
||||
else
|
||||
{
|
||||
string environment;
|
||||
if (Staging)
|
||||
environment = nameof(Staging);
|
||||
else if (Development)
|
||||
environment = nameof(Development);
|
||||
else
|
||||
throw new Exception();
|
||||
if (processesCount is null)
|
||||
result = $"appsettings.{environment}.json";
|
||||
else
|
||||
result = $"appsettings.{environment}.{processesCount}.json";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string GetEnvironmentName(IsEnvironment isEnvironment)
|
||||
{
|
||||
string result;
|
||||
if (isEnvironment.Windows)
|
||||
result = nameof(Windows);
|
||||
else if (isEnvironment.Linux)
|
||||
result = nameof(Linux);
|
||||
else if (isEnvironment.OSX)
|
||||
result = nameof(OSX);
|
||||
else
|
||||
throw new Exception();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Phares.Shared.Models.Stateless.Methods;
|
||||
|
||||
public interface IMethodName
|
||||
{
|
||||
|
||||
static string? GetActualAsyncMethodName([CallerMemberName] string? name = null) => name;
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
namespace Phares.Shared.Models.Stateless.Methods;
|
||||
|
||||
public interface IWorkingDirectory
|
||||
{
|
||||
|
||||
static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName) => WorkingDirectory.GetWorkingDirectory(executingAssemblyName, subDirectoryName);
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
namespace Phares.Shared.Models.Stateless.Methods;
|
||||
|
||||
internal abstract class WorkingDirectory
|
||||
{
|
||||
|
||||
internal static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName)
|
||||
{
|
||||
string result = string.Empty;
|
||||
if (executingAssemblyName is null)
|
||||
throw new Exception();
|
||||
string traceFile;
|
||||
List<string> directories = new();
|
||||
Environment.SpecialFolder[] specialFolders = new Environment.SpecialFolder[]
|
||||
{
|
||||
Environment.SpecialFolder.LocalApplicationData,
|
||||
Environment.SpecialFolder.ApplicationData,
|
||||
Environment.SpecialFolder.History,
|
||||
Environment.SpecialFolder.CommonApplicationData,
|
||||
Environment.SpecialFolder.InternetCache
|
||||
};
|
||||
foreach (Environment.SpecialFolder specialFolder in specialFolders)
|
||||
directories.Add(Path.Combine(Environment.GetFolderPath(specialFolder), subDirectoryName, executingAssemblyName));
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
if (i == 1)
|
||||
result = directory;
|
||||
else
|
||||
result = string.Concat("D", directory[1..]);
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(result))
|
||||
_ = Directory.CreateDirectory(result);
|
||||
traceFile = Path.Combine(result, $"{DateTime.Now.Ticks}.txt");
|
||||
File.WriteAllText(traceFile, traceFile);
|
||||
File.Delete(traceFile);
|
||||
break;
|
||||
}
|
||||
catch (Exception) { result = string.Empty; }
|
||||
}
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
break;
|
||||
}
|
||||
if (string.IsNullOrEmpty(result))
|
||||
throw new Exception("Unable to set working directory!");
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
157
Program.cs
157
Program.cs
@ -1,156 +1,27 @@
|
||||
using File_Folder_Helper.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Phares.Shared.Models;
|
||||
using Phares.Shared.Models.Stateless.Methods;
|
||||
using Serilog;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace File_Folder_Helper;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
|
||||
public static void Secondary(List<string> args)
|
||||
{
|
||||
LoggerConfiguration loggerConfiguration = new();
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
|
||||
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
||||
IConfigurationRoot configurationRoot = configurationBuilder.Build();
|
||||
AppSettings appSettings = Models.Stateless.AppSettings.Get(configurationRoot);
|
||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||
throw new Exception("Working directory name must have a value!");
|
||||
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
|
||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
|
||||
Log.Logger = loggerConfiguration.CreateLogger();
|
||||
ILogger log = Log.ForContext<Program>();
|
||||
int silentIndex = args.IndexOf("s");
|
||||
if (silentIndex > -1)
|
||||
args.RemoveAt(silentIndex);
|
||||
try
|
||||
{
|
||||
int? singleCharIndex = null;
|
||||
ConsoleKey consoleKey = ConsoleKey.End;
|
||||
ConsoleKey[] consoleKeys = new ConsoleKey[]
|
||||
{
|
||||
ConsoleKey.A,
|
||||
ConsoleKey.B,
|
||||
ConsoleKey.C,
|
||||
ConsoleKey.D,
|
||||
ConsoleKey.E,
|
||||
ConsoleKey.F,
|
||||
ConsoleKey.L,
|
||||
ConsoleKey.N,
|
||||
ConsoleKey.R,
|
||||
ConsoleKey.T,
|
||||
ConsoleKey.Z,
|
||||
ConsoleKey.Delete
|
||||
};
|
||||
for (int i = 0; i < args.Count; i++)
|
||||
{
|
||||
if (args[i].Length == 1 && Enum.TryParse(args[i], out consoleKey) && consoleKeys.Contains(consoleKey))
|
||||
{
|
||||
singleCharIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (consoleKey is not ConsoleKey.End && !consoleKeys.Contains(consoleKey))
|
||||
consoleKey = ConsoleKey.End;
|
||||
if (singleCharIndex is not null)
|
||||
args.RemoveAt(singleCharIndex.Value);
|
||||
if (!args.Any())
|
||||
log.Information("Must pass a argument!");
|
||||
else if (Directory.Exists(args[0]) && File.Exists(Path.Combine(args[0], string.Concat(Path.GetFileName(args[0]), ".dll"))))
|
||||
Helpers.HelperILMerge.ILMerge(args[0]);
|
||||
else if (Directory.Exists(args[0]))
|
||||
{
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
if (consoleKeys.Contains(consoleKey))
|
||||
break;
|
||||
log.Information("A) Save (Top Directory Only),");
|
||||
log.Information("B) Save (All Directories),");
|
||||
log.Information("C) Clipboard (Top Directory Only),");
|
||||
log.Information("D) Clipboard (All Directories),");
|
||||
log.Information("E) Clipboard (Top Directory Only and File Name Without Extension),");
|
||||
log.Information("F) Clipboard (All Directories and File Name Without Extension),");
|
||||
log.Information("L) Log Merge (APC Log [0-9{8}]_*.log),");
|
||||
log.Information("N) Create Note Files,");
|
||||
log.Information("R) Rename to old, copy, delete old");
|
||||
log.Information("T) Too long rename");
|
||||
log.Information("Z) Zip file(s) by date,");
|
||||
log.Information("Delete) Delete empty directories,");
|
||||
consoleKey = Console.ReadKey().Key;
|
||||
log.Information(string.Empty);
|
||||
}
|
||||
switch (consoleKey)
|
||||
{
|
||||
case ConsoleKey.A:
|
||||
case ConsoleKey.B:
|
||||
case ConsoleKey.C:
|
||||
case ConsoleKey.E:
|
||||
case ConsoleKey.F:
|
||||
Helpers.HelperSaveOrCopyContents.SaveOrCopyContents(log, args[0], consoleKey);
|
||||
break;
|
||||
case ConsoleKey.L:
|
||||
Helpers.HelperLogMerge.LogMerge(args[0]);
|
||||
break;
|
||||
case ConsoleKey.N:
|
||||
Helpers.HelperCreateNoteFiles.CreateNoteFiles(args[0]);
|
||||
break;
|
||||
case ConsoleKey.R:
|
||||
Helpers.HelperRenameToOldMoveDeleteOldMerge.RenameToOldMoveDeleteOld(log, args[0]);
|
||||
break;
|
||||
case ConsoleKey.T:
|
||||
Helpers.HelperTooLong.TooLong(args[0], delete: false);
|
||||
Helpers.HelperTooLong.TooLong(args[0], delete: true);
|
||||
break;
|
||||
case ConsoleKey.Z:
|
||||
Helpers.HelperZipFilesByDate.ZipFilesByDate(log, args[0]);
|
||||
break;
|
||||
default:
|
||||
switch (consoleKey)
|
||||
{
|
||||
case ConsoleKey.Delete:
|
||||
for (int j = 1; j < 6; j++)
|
||||
{
|
||||
if (!Helpers.HelperDeleteEmptyDirectories.DeleteEmptyDirectories(args[0]))
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new Exception(args[0]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
|
||||
}
|
||||
if (silentIndex > -1)
|
||||
Console.WriteLine("Done. Bye");
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Done. Press 'Enter' to end");
|
||||
_ = Console.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
if (args is not null)
|
||||
Secondary(args.ToList());
|
||||
else
|
||||
Secondary(new List<string>());
|
||||
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
|
||||
_ = builder.Configuration.AddEnvironmentVariables();
|
||||
_ = builder.Configuration.AddUserSecrets<Program>();
|
||||
_ = builder.Services.AddSingleton(args.ToList());
|
||||
AppSettings appSettings = Models.Binder.AppSettings.Get(builder.Configuration);
|
||||
_ = builder.Services.AddSingleton(appSettings);
|
||||
_ = builder.Services.AddHostedService<Worker>();
|
||||
using IHost host = builder.Build();
|
||||
ILogger<Program> logger = host.Services.GetRequiredService<ILogger<Program>>();
|
||||
logger.LogCritical(appSettings.Company);
|
||||
host.Run();
|
||||
}
|
||||
|
||||
}
|
180
Worker.cs
Normal file
180
Worker.cs
Normal file
@ -0,0 +1,180 @@
|
||||
using File_Folder_Helper.Models;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace File_Folder_Helper;
|
||||
|
||||
public class Worker : BackgroundService
|
||||
{
|
||||
|
||||
private readonly bool _IsSilent;
|
||||
private readonly List<string> _Args;
|
||||
private readonly ILogger<Worker> _Logger;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly ConsoleKey[] _ConsoleKeys;
|
||||
private readonly IHostApplicationLifetime _Lifetime;
|
||||
|
||||
public Worker(ILogger<Worker> logger, IHostApplicationLifetime lifetime, List<string> args, AppSettings appSettings)
|
||||
{
|
||||
_Args = args;
|
||||
_Logger = logger;
|
||||
_Lifetime = lifetime;
|
||||
_AppSettings = appSettings;
|
||||
int silentIndex = args.IndexOf("s");
|
||||
_IsSilent = silentIndex > -1;
|
||||
if (_IsSilent)
|
||||
args.RemoveAt(silentIndex);
|
||||
_ConsoleKeys = new ConsoleKey[]
|
||||
{
|
||||
ConsoleKey.A,
|
||||
ConsoleKey.B,
|
||||
ConsoleKey.C,
|
||||
ConsoleKey.D,
|
||||
ConsoleKey.E,
|
||||
ConsoleKey.F,
|
||||
ConsoleKey.H,
|
||||
ConsoleKey.J,
|
||||
ConsoleKey.K,
|
||||
ConsoleKey.L,
|
||||
ConsoleKey.M,
|
||||
ConsoleKey.N,
|
||||
ConsoleKey.R,
|
||||
ConsoleKey.S,
|
||||
ConsoleKey.T,
|
||||
ConsoleKey.Z,
|
||||
ConsoleKey.Delete
|
||||
};
|
||||
}
|
||||
|
||||
public override Task StartAsync(CancellationToken cancellationToken) =>
|
||||
base.StartAsync(cancellationToken);
|
||||
|
||||
public override Task StopAsync(CancellationToken cancellationToken) =>
|
||||
base.StopAsync(cancellationToken);
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
if (!stoppingToken.IsCancellationRequested)
|
||||
await Task.Delay(500, stoppingToken);
|
||||
if (_AppSettings is null)
|
||||
throw new NullReferenceException(nameof(_AppSettings));
|
||||
try
|
||||
{
|
||||
int? singleCharIndex = null;
|
||||
ConsoleKey consoleKey = ConsoleKey.End;
|
||||
for (int i = 0; i < _Args.Count; i++)
|
||||
{
|
||||
if (_Args[i].Length == 1 && Enum.TryParse(_Args[i], out consoleKey) && _ConsoleKeys.Contains(consoleKey))
|
||||
{
|
||||
singleCharIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (consoleKey is not ConsoleKey.End && !_ConsoleKeys.Contains(consoleKey))
|
||||
consoleKey = ConsoleKey.End;
|
||||
if (singleCharIndex is not null)
|
||||
_Args.RemoveAt(singleCharIndex.Value);
|
||||
if (!_Args.Any())
|
||||
_Logger.LogInformation("Must pass a argument!");
|
||||
else if (_Args[0].EndsWith(".kanbn") && Directory.Exists(_Args[0]))
|
||||
Helpers.HelperKanbanMetadata.SetMetadata(_Logger, _AppSettings, _Args[0]);
|
||||
else if (Directory.Exists(_Args[0]) && File.Exists(Path.Combine(_Args[0], string.Concat(Path.GetFileName(_Args[0]), ".dll"))))
|
||||
Helpers.HelperILMerge.ILMerge(_Args[0]);
|
||||
else if (Directory.Exists(_Args[0]))
|
||||
{
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
if (_ConsoleKeys.Contains(consoleKey))
|
||||
break;
|
||||
_Logger.LogInformation("A) Save (Top Directory Only),");
|
||||
_Logger.LogInformation("B) Save (All Directories),");
|
||||
_Logger.LogInformation("C) Clipboard (Top Directory Only),");
|
||||
_Logger.LogInformation("D) Clipboard (All Directories),");
|
||||
_Logger.LogInformation("E) Clipboard (Top Directory Only and File Name Without Extension),");
|
||||
_Logger.LogInformation("F) Clipboard (All Directories and File Name Without Extension),");
|
||||
_Logger.LogInformation("H) Hardcoded file search and sort,");
|
||||
_Logger.LogInformation("J) Set Date from Json Entry");
|
||||
_Logger.LogInformation("K) Kanban support");
|
||||
_Logger.LogInformation("L) Log Merge (APC Log [0-9(8)]_*.log),");
|
||||
_Logger.LogInformation("N) Create Note Files,");
|
||||
_Logger.LogInformation("M) Markdown Wiki Link Verification,");
|
||||
_Logger.LogInformation("R) Rename to old, copy, delete old");
|
||||
_Logger.LogInformation("S) Set Date from Zip Entry");
|
||||
_Logger.LogInformation("T) Too long rename");
|
||||
_Logger.LogInformation("Z) Zip file(s) by date,");
|
||||
_Logger.LogInformation("Delete) Delete empty directories,");
|
||||
consoleKey = Console.ReadKey().Key;
|
||||
_Logger.LogInformation(" ");
|
||||
}
|
||||
switch (consoleKey)
|
||||
{
|
||||
case ConsoleKey.A:
|
||||
case ConsoleKey.B:
|
||||
case ConsoleKey.C:
|
||||
case ConsoleKey.E:
|
||||
case ConsoleKey.F:
|
||||
Helpers.HelperSaveOrCopyContents.SaveOrCopyContents(_Logger, _Args[0], consoleKey);
|
||||
break;
|
||||
case ConsoleKey.H:
|
||||
Helpers.HelperHardcodedFileSearchAndSort.HardcodedFileSearchAndSort(_Logger, _Args[0]);
|
||||
break;
|
||||
case ConsoleKey.J:
|
||||
Helpers.HelperPackageFilesByDate.SetDateFromJsonEntry(_Logger, _Args[0]);
|
||||
break;
|
||||
case ConsoleKey.K:
|
||||
Helpers.HelperKanbanMetadata.SetMetadata(_Logger, _AppSettings, _Args[0]);
|
||||
break;
|
||||
case ConsoleKey.L:
|
||||
Helpers.HelperLogMerge.LogMerge(_Args[0]);
|
||||
break;
|
||||
case ConsoleKey.N:
|
||||
Helpers.HelperCreateNoteFiles.CreateNoteFiles(_Args[0]);
|
||||
break;
|
||||
case ConsoleKey.M:
|
||||
Helpers.HelperMarkdown.MarkdownWikiLinkVerification(_AppSettings, _Args[0]);
|
||||
break;
|
||||
case ConsoleKey.R:
|
||||
Helpers.HelperRenameToOldMoveDeleteOldMerge.RenameToOldMoveDeleteOld(_Logger, _Args[0]);
|
||||
break;
|
||||
case ConsoleKey.S:
|
||||
Helpers.HelperZipFilesByDate.SetDateFromZipEntry(_Logger, _Args[0]);
|
||||
break;
|
||||
case ConsoleKey.T:
|
||||
Helpers.HelperTooLong.TooLong(_Args[0], delete: false);
|
||||
Helpers.HelperTooLong.TooLong(_Args[0], delete: true);
|
||||
break;
|
||||
case ConsoleKey.Z:
|
||||
Helpers.HelperZipFilesByDate.ZipFilesByDate(_Logger, _Args[0]);
|
||||
break;
|
||||
default:
|
||||
switch (consoleKey)
|
||||
{
|
||||
case ConsoleKey.Delete:
|
||||
for (int j = 1; j < 6; j++)
|
||||
{
|
||||
if (!Helpers.HelperDeleteEmptyDirectories.DeleteEmptyDirectories(_Args[0]))
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new Exception(_Args[0]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ _Logger.LogError(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace)); }
|
||||
if (_IsSilent)
|
||||
_Logger.LogInformation("Done. Bye");
|
||||
else
|
||||
{
|
||||
_Logger.LogInformation("Done. Press 'Enter' to end");
|
||||
_ = Console.ReadLine();
|
||||
}
|
||||
_Lifetime.StopApplication();
|
||||
}
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
{
|
||||
"Company": "Infineon Technologies Americas Corp.",
|
||||
"Linux": {},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Log4netProvider": "Debug",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
"Serilog.Sinks.File"
|
||||
],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Debug",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "Console",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "%workingDirectory% - Log/log-.txt",
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
|
||||
"rollingInterval": "Hour"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [
|
||||
"FromLogContext",
|
||||
"WithMachineName",
|
||||
"WithThreadId"
|
||||
],
|
||||
"Properties": {
|
||||
"Application": "Sample"
|
||||
}
|
||||
},
|
||||
"WorkingDirectoryName": "IFXApps",
|
||||
"Windows": {}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
{
|
||||
"Company": "Infineon Technologies Americas Corp.",
|
||||
"Linux": {},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Log4netProvider": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
"Serilog.Sinks.File"
|
||||
],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Debug",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "Console",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "%workingDirectory% - Log/log-.txt",
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
|
||||
"rollingInterval": "Hour"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [
|
||||
"FromLogContext",
|
||||
"WithMachineName",
|
||||
"WithThreadId"
|
||||
],
|
||||
"Properties": {
|
||||
"Application": "Sample"
|
||||
}
|
||||
},
|
||||
"WorkingDirectoryName": "IFXApps",
|
||||
"Windows": {}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
{
|
||||
"Company": "Infineon Technologies Americas Corp.",
|
||||
"Linux": {},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Log4netProvider": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
"Serilog.Sinks.File"
|
||||
],
|
||||
"MinimumLevel": "Information",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Debug",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "Console",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "%workingDirectory% - Log/log-.txt",
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
|
||||
"rollingInterval": "Hour"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [
|
||||
"FromLogContext",
|
||||
"WithMachineName",
|
||||
"WithThreadId"
|
||||
],
|
||||
"Properties": {
|
||||
"Application": "Sample"
|
||||
}
|
||||
},
|
||||
"WorkingDirectoryName": "IFXApps",
|
||||
"Windows": {}
|
||||
}
|
35
package-lock.json
generated
Normal file
35
package-lock.json
generated
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "File-Folder-Helper",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"devDependencies": {
|
||||
"prettier": "3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "http://localhost:4873/prettier/-/prettier-3.0.0.tgz",
|
||||
"integrity": "sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"prettier": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "http://localhost:4873/prettier/-/prettier-3.0.0.tgz",
|
||||
"integrity": "sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"scripts": {
|
||||
"prettier.check": "prettier . --check",
|
||||
"prettier.write": "prettier . --write",
|
||||
"Alpha": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
"nuget-clear": "dotnet nuget locals all --clear",
|
||||
"build": "dotnet build --runtime win-x64 --self-contained",
|
||||
@ -10,5 +12,8 @@
|
||||
"MSBuild": "\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe\" /target:Build /restore:True /p:RestoreSources=https://api.nuget.org/v3/index.json%3Bhttps://packagemanagement.eu.infineon.com:4430/api/v2/%3Bhttps://tfs.intra.infineon.com/tfs/ManufacturingIT/_packaging/eaf/nuget/v3/index.json /DetailedSummary /ConsoleLoggerParameters:PerformanceSummary;ErrorsOnly; /property:Configuration=Debug;TargetFrameworkVersion=v4.8 File-Folder-Helper.csproj",
|
||||
"pull": "git pull",
|
||||
"garbage-collect": "git gc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "3.0.0"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user