Mass push

This commit is contained in:
2022-12-16 11:26:00 -07:00
parent ae1baaaf46
commit 33c5ce6e23
132 changed files with 5869 additions and 3712 deletions

View File

@ -34,9 +34,9 @@
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
<PackageReference Include="MetadataExtractor" Version="2.7.2" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
@ -46,13 +46,16 @@
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
<PackageReference Include="WindowsShortcutFactory" Version="1.1.0" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Text.Json" Version="7.0.0" />
<PackageReference Include="System.Text.Json" Version="7.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
<ProjectReference Include="..\Property\Property.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

View File

@ -36,8 +36,9 @@ public class DateGroup
_FileKeyValuePairs = new List<KeyValuePair<string, string>>();
_FilePropertiesKeyValuePairs = new Dictionary<string, List<Tuple<string, Shared.Models.Property>>>();
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: true);
Models.Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
_Log.Information(propertyConfiguration.RootDirectory);
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: true);
Verify(configuration);
bool reverse = false;
_Configuration = configuration;
@ -141,8 +142,6 @@ public class DateGroup
check += 1;
if (configuration.ByHash)
check += 1;
if (configuration.ByNone)
check += 1;
if (configuration.BySeason)
check += 1;
if (configuration.ByWeek)
@ -256,18 +255,15 @@ public class DateGroup
if (matches is not null && matches.Any())
break;
}
matches ??= Array.Empty<string>();
foreach (Item item in filteredItems)
{
if (item.Property is null || (_Configuration.PropertyConfiguration.PopulatePropertyId && item.Property.Id is null))
continue;
directoryNames.Clear();
destinationCollection = new();
_ = destinationDirectoryName.Clear();
minimumDateTime = Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(item.Property);
day = minimumDateTime.Value.ToString("MM-dd");
month = minimumDateTime.Value.ToString("MMMM");
if (item.Property.Id is null)
if (item.Property?.Id is null)
{
flag = '#';
isWrongYear = null;
@ -294,6 +290,8 @@ public class DateGroup
seasonValue = $".{season}";
if (isWrongYear is null || !isWrongYear.Value)
year = $"{flag}{minimumDateTime.Value:yyyy}{seasonValue}";
else if (matches is null || matches.Length < 3)
year = "----";
else
{
if (matches[0][0] != '~')
@ -303,9 +301,7 @@ public class DateGroup
}
topDirectoryName = Path.GetFileName(topDirectory);
weekOfYear = calendar.GetWeekOfYear(minimumDateTime.Value, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
if (_Configuration.ByNone)
directoryNames.Clear();
else if (_Configuration.ByHash)
if (_Configuration.ByHash)
directoryNames.Add($"{year} {seasonName}");
else if (_Configuration.BySeason && topDirectoryName.Length == 1 && topDirectoryName[0] == '_')
directoryNames.Add($"{year} {seasonName}");
@ -328,7 +324,7 @@ public class DateGroup
{
foreach (string sourceDirectoryNameSegment in topDirectorySegments)
{
if (matches.Contains(sourceDirectoryNameSegment))
if (matches is not null && matches.Contains(sourceDirectoryNameSegment))
_ = destinationDirectoryName.Append(year);
else
_ = destinationDirectoryName.Append(sourceDirectoryNameSegment);
@ -343,14 +339,19 @@ public class DateGroup
throw new Exception();
}
}
if (!_Configuration.ByHash || item.Property.Id is null)
if (!_Configuration.ByHash || item.Property?.Id is null)
fileName = item.ImageFileHolder.Name;
else
fileName = $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}";
destinationCollection.Add(destinationDirectory);
destinationCollection.AddRange(directoryNames);
destinationCollection.Add(fileName);
results.Add(new(item, item.Property.LastWriteTime.Ticks, minimumDateTime.Value.Ticks, destinationCollection.ToArray()));
if (item.ImageFileHolder.LastWriteTime is null)
continue;
if (item.Property is not null)
results.Add(new(item, item.Property.LastWriteTime.Ticks, minimumDateTime.Value.Ticks, destinationCollection.ToArray()));
else
results.Add(new(item, item.ImageFileHolder.LastWriteTime.Value.Ticks, minimumDateTime.Value.Ticks, destinationCollection.ToArray()));
}
return results;
}
@ -419,11 +420,12 @@ public class DateGroup
{
if (_Log is null)
throw new NullReferenceException(nameof(_Log));
string checkDirectory;
bool hasDuplicate;
string fullFileName;
string directoryName;
WindowsShortcut windowsShortcut;
string duplicate = "-Duplicate";
string duplicate = "-Duplicates";
List<string> filesDistinct = new();
List<string> filesDuplicate = new();
List<string> directoriesDistinct = new();
@ -440,12 +442,17 @@ public class DateGroup
directoriesDistinct.Add(directoryName);
if (!Directory.Exists(directoryName))
_ = Directory.CreateDirectory(directoryName);
if (!Directory.Exists(string.Concat(directoryName, duplicate, " I")))
_ = Directory.CreateDirectory(string.Concat(directoryName, duplicate, " I"));
if (!Directory.Exists(string.Concat(directoryName, duplicate, " II")))
_ = Directory.CreateDirectory(string.Concat(directoryName, duplicate, " II"));
checkDirectory = Path.Combine(string.Concat(directoryName, duplicate), "I");
if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory);
for (int i = 0; i < 200 - checkDirectory.Length; i++)
{
checkDirectory = string.Concat(checkDirectory, "I");
if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory);
}
}
_Log.Information("Ready to move files?");
_Log.Information($"Ready to move {fileMoveCollectionAll.Length} file(s)?");
for (int y = 0; y < int.MaxValue; y++)
{
_Log.Information("Press \"Y\" key to move file(s) or close console to not move files");
@ -460,16 +467,16 @@ public class DateGroup
hasDuplicate = filesDuplicate.Contains(fullFileName);
if (hasDuplicate)
{
destination[1] = string.Concat(destination[1], duplicate, " I");
destination[0] = Path.Combine(string.Concat(destination[0], duplicate), "I");
fullFileName = Path.Combine(destination);
}
for (int i = 0; i < 256 - destination[1].Length; i++)
for (int i = 0; i < 200 - destination[0].Length; i++)
{
if (!File.Exists(fullFileName))
break;
else
{
destination[1] = string.Concat(destination[1], "I");
destination[0] = string.Concat(destination[0], "I");
fullFileName = Path.Combine(destination);
if (File.Exists(fullFileName))
continue;

View File

@ -13,7 +13,6 @@ public class Configuration
[Display(Name = "By Create Date Shortcut"), Required] public bool? ByCreateDateShortcut { get; set; }
[Display(Name = "By Date"), Required] public bool? ByDay { get; set; }
[Display(Name = "By Hash"), Required] public bool? ByHash { get; set; }
[Display(Name = "By None"), Required] public bool? ByNone { get; set; }
[Display(Name = "By Season"), Required] public bool? BySeason { get; set; }
[Display(Name = "By Week"), Required] public bool? ByWeek { get; set; }
[Display(Name = "Ignore Subdirectories for Rename"), Required] public bool? KeepFullPath { get; set; }
@ -38,15 +37,20 @@ public class Configuration
throw new NullReferenceException(nameof(configuration.ByDay));
if (configuration.ByHash is null)
throw new NullReferenceException(nameof(configuration.ByHash));
if (configuration.ByNone is null)
throw new NullReferenceException(nameof(configuration.ByNone));
if (configuration.BySeason is null)
throw new NullReferenceException(nameof(configuration.BySeason));
if (configuration.ByWeek is null)
throw new NullReferenceException(nameof(configuration.ByWeek));
if (configuration.KeepFullPath is null)
throw new NullReferenceException(nameof(configuration.KeepFullPath));
result = new(configuration.PropertyConfiguration, configuration.ByCreateDateShortcut.Value, configuration.ByDay.Value, configuration.ByHash.Value, configuration.ByNone.Value, configuration.BySeason.Value, configuration.ByWeek.Value, configuration.KeepFullPath.Value);
result = new(
configuration.PropertyConfiguration,
configuration.ByCreateDateShortcut.Value,
configuration.ByDay.Value,
configuration.ByHash.Value,
configuration.BySeason.Value,
configuration.ByWeek.Value,
configuration.KeepFullPath.Value);
return result;
}
@ -66,7 +70,7 @@ public class Configuration
result = Get(configuration);
if (configuration is null)
throw new NullReferenceException(nameof(configuration));
result.SetAndUpdate(propertyConfiguration, numberOfJitters: null, numberOfTimesToUpsample: null, modelName: null, predictorModelName: null);
result.SetAndUpdate(propertyConfiguration);
return result;
}

View File

@ -12,17 +12,15 @@ public class Configuration
public bool ByCreateDateShortcut { init; get; }
public bool ByDay { init; get; }
public bool ByHash { init; get; }
public bool ByNone { init; get; }
public bool BySeason { init; get; }
public bool ByWeek { init; get; }
public bool KeepFullPath { init; get; }
[JsonConstructor]
public Configuration(Property.Models.Configuration propertyConfiguration, bool byCreateDateShortcut, bool byDay, bool byHash, bool byNone, bool bySeason, bool byWeek, bool keepFullPath)
public Configuration(Property.Models.Configuration propertyConfiguration, bool byCreateDateShortcut, bool byDay, bool byHash, bool bySeason, bool byWeek, bool keepFullPath)
{
ByDay = byDay;
ByHash = byHash;
ByNone = byNone;
ByWeek = byWeek;
BySeason = bySeason;
KeepFullPath = keepFullPath;
@ -36,10 +34,10 @@ public class Configuration
return result;
}
public void SetAndUpdate(Property.Models.Configuration configuration, int? numberOfJitters, int? numberOfTimesToUpsample, string? modelName, string? predictorModelName)
public void SetAndUpdate(Property.Models.Configuration configuration)
{
_PropertyConfiguration = configuration;
_PropertyConfiguration.Update(numberOfJitters, numberOfTimesToUpsample, modelName, predictorModelName);
_PropertyConfiguration.Update();
}
}

View File

@ -19,6 +19,7 @@ public class Program
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
IConfigurationRoot configurationRoot = configurationBuilder.Build();
AppSettings appSettings = Models.Binder.AppSettings.Get(configurationRoot);

View File

@ -53,8 +53,7 @@
"ByCreateDateShortcut": false,
"ByDay": false,
"ByHash": false,
"ByNone": false,
"BySeason": true,
"BySeason": false,
"ByWeek": false,
"DateGroup": "2022-11-12",
"FileNameDirectorySeparator": ".Z.",
@ -69,10 +68,10 @@
"ResultContent": "()",
"ResultSingleton": "{}",
"xRootDirectory": "C:/Tmp/phares/Pictures",
"xxRootDirectory": "C:/Tmp/Phares/Compare/Images 2022-11-12 - c6aa7e8 - III",
"xxxRootDirectory": "F:/Tmp/Phares/Compare/Images 2022-11-12 - c6aa7e8 - III",
"xxRootDirectory": "C:/Tmp/Phares/Compare/Images 2022-11-12 - c6aa7e8",
"xxxRootDirectory": "F:/Tmp/Phares/Compare/Not-Copy-Copy-All",
"RootDirectory": "C:/Tmp/Phares/Compare/Not-Copy-Copy-All",
"xxxxRootDirectory": "F:/Tmp/Phares/2022-11-03-DCIM/DCIM/100D3400 2022",
"RootDirectory": "F:/Tmp/Phares/Compare/Images 2022-11-12 - c6aa7e8 - III/D",
"WriteBitmapDataBytes": false,
"IgnoreExtensions": [
".gif",

348
Date-Group/appsettings.json Normal file
View File

@ -0,0 +1,348 @@
{
"Company": "Mike Phares",
"Linux": {},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Log4netProvider": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"MaxDegreeOfParallelism": 6,
"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": "PharesApps",
"Windows": {
"Configuration": {
"ByCreateDateShortcut": false,
"ByDay": false,
"ByHash": false,
"BySeason": false,
"ByWeek": false,
"DateGroup": "2022-11-12",
"FileNameDirectorySeparator": ".Z.",
"ForcePropertyLastWriteTimeToCreationTime": false,
"KeepFullPath": false,
"MaxImagesInDirectoryForTopLevelFirstPass": 10,
"Pattern": "[^ABCDEFGHIJKLMNOPQRSTUVWXYZbcdfghjklmnpqrstvwxyz0-9]",
"PopulatePropertyId": false,
"PropertiesChangedForProperty": false,
"ResultAllInOne": "_ _ _",
"ResultCollection": "[]",
"ResultContent": "()",
"ResultSingleton": "{}",
"xRootDirectory": "C:/Tmp/phares/Pictures",
"xxRootDirectory": "C:/Tmp/Phares/Compare/Images 2022-11-12 - c6aa7e8",
"RootDirectory": "F:/Tmp/Phares/Compare/Not-Copy-Copy-All",
"xxxxRootDirectory": "F:/Tmp/Phares/2022-11-03-DCIM/DCIM/100D3400 2022",
"WriteBitmapDataBytes": false,
"IgnoreExtensions": [
".gif",
".GIF"
],
"PropertyContentCollectionFiles": [],
"ValidImageFormatExtensions": [
".bmp",
".BMP",
".gif",
".GIF",
".jpeg",
".JPEG",
".jpg",
".JPG",
".png",
".PNG",
".tiff",
".TIFF"
],
"ValidMetadataExtensions": [
".3gp",
".3GP",
".avi",
".AVI",
".bmp",
".BMP",
".gif",
".GIF",
".ico",
".ICO",
".jpeg",
".JPEG",
".jpg",
".JPG",
".m4v",
".M4V",
".mov",
".MOV",
".mp4",
".MP4",
".mta",
".MTA",
".png",
".PNG",
".tiff",
".TIFF"
],
"VerifyToSeason": [
". 2000",
". 2001",
". 2002",
". 2003",
". 2004",
". 2005",
". 2006",
". 2007",
". 2008",
". 2009",
". 2010",
". 2011",
". 2012",
". 2013",
". 2014",
". 2015",
". 2016",
". 2017",
". 2018",
". 2019",
". 2020",
". 2021",
". 2022",
". 2023",
". 2024",
". 2025",
". 2026",
". 2027",
". 2028",
". 2029",
"=2000.0 Winter",
"=2002.1 Spring",
"=2002.4 Winter",
"=2003.0 Winter",
"=2003.1 Spring",
"=2003.3 Fall",
"=2003.4 Winter",
"=2004.0 Winter",
"=2005.1 Spring",
"=2005.2 Summer",
"=2005.3 Fall",
"=2005.4 Winter",
"=2006.0 Winter",
"=2006.1 Spring",
"=2006.3 Fall",
"=2007.0 Winter",
"=2007.2 Summer Logan Michael",
"=2007.2 Summer",
"=2007.3 Fall Logan Michael",
"=2007.4 Winter Logan Michael",
"=2008.0 Winter Logan Michael",
"=2008.1 Spring Logan Michael",
"=2008.2 Summer Logan Michael",
"=2008.2 Summer",
"=2008.3 Fall Logan Michael",
"=2009.0 Winter Logan Michael",
"=2009.0 Winter",
"=2009.1 Spring Logan Michael",
"=2009.1 Spring",
"=2009.2 Summer Logan Michael",
"=2009.2 Summer",
"=2009.3 Fall Logan Michael",
"=2009.3 Fall",
"=2009.4 Winter Logan Michael",
"=2009.4 Winter",
"=2010.0 Winter Logan Michael",
"=2010.0 Winter",
"=2010.1 Spring Logan Michael",
"=2010.1 Spring",
"=2010.2 Summer",
"=2010.3 Fall Logan Michael",
"=2010.3 Fall",
"=2010.4 Winter",
"=2011.0 Winter",
"=2011.1 Spring",
"=2011.2 Summer",
"=2011.3 Fall",
"=2011.4 Winter",
"=2012.0 Winter Chelsea 2012",
"=2012.0 Winter Chelsea",
"=2012.0 Winter",
"=2012.1 Spring Chelsea",
"=2012.1 Spring",
"=2012.2 Summer Chelsea",
"=2012.2 Summer",
"=2012.3 Fall Chelsea",
"=2012.3 Fall",
"=2012.4 Winter Chelsea",
"=2012.4 Winter",
"=2013.0 Winter Chelsea 2013",
"=2013.0 Winter Chelsea",
"=2013.0 Winter",
"=2013.1 Spring",
"=2013.2 Summer Chelsea",
"=2013.2 Summer",
"=2013.3 Fall Chelsea",
"=2013.3 Fall",
"=2013.4 Winter",
"=2014.0 Winter",
"=2014.1 Spring",
"=2014.2 Summer",
"=2014.3 Fall",
"=2014.4 Winter",
"=2015.0 Winter",
"=2015.1 Spring",
"=2015.2 Summer",
"=2015.3 Fall",
"=2015.4 Winter",
"=2016.0 Winter",
"=2016.1 Spring",
"=2016.2 Summer",
"=2016.3 Fall",
"=2016.4 Winter",
"=2017.1 Spring",
"=2017.2 Summer",
"=2017.3 Fall",
"=2017.4 Winter",
"=2018.0 Winter",
"=2018.1 Spring",
"=2018.3 Fall",
"=2018.4 Winter",
"=2019.0 Winter",
"=2019.1 Spring",
"=2019.2 Summer",
"=2019.3 Fall",
"=2019.4 Winter",
"=2020.0 Winter",
"=2020.1 Spring",
"=2020.2 Summer",
"=2020.3 Fall",
"=2020.4 Winter",
"=2021.1 Spring",
"=2021.2 Summer",
"=2021.3 Fall",
"=2021.4 Winter",
"=2022.0 Winter",
"=2022.1 Spring",
"Anthem 2015",
"April 2010",
"April 2013",
"December 2006",
"December 2010",
"Fall 2005",
"Fall 2015",
"Fall 2016",
"Fall 2017",
"Fall 2018",
"Fall 2019",
"Fall 2020",
"Fall 2021",
"February 2010",
"January 2015",
"July 2010",
"June 2010",
"Kids 2005",
"March 2013",
"May 2010",
"May 2011",
"May 2013",
"October 2005",
"October 2014",
"Spring 2013",
"Spring 2014",
"Spring 2016",
"Spring 2018",
"Spring 2019",
"Spring 2020",
"Summer 2011",
"Summer 2012",
"Summer 2013",
"Summer 2014",
"Summer 2015",
"Summer 2016",
"Summer 2017",
"Summer 2018",
"Summer 2020",
"Summer 2021",
"Winter 2015",
"Winter 2016",
"Winter 2017",
"Winter 2018",
"Winter 2019-2020",
"Winter 2020",
"zzz =2005.0 Winter Tracy Pictures",
"zzz =2005.1 Spring Tracy Pictures",
"zzz =2005.2 Summer Tracy Pictures",
"zzz =2005.3 Fall Tracy Pictures",
"zzz =2005.4 Winter Tracy Pictures",
"zzz =2006.1 Spring Tracy Pictures",
"zzz =2007.0 Winter Tracy Pictures",
"zzz =2007.2 Summer Tracy Pictures",
"zzz =2008.0 Winter Tracy Pictures",
"zzz =2008.2 Summer Tracy Pictures",
"zzz =2009.0 Winter Tracy Pictures",
"zzz =2009.2 Summer Tracy Pictures",
"zzz =2009.3 Fall Tracy Pictures",
"zzz =2009.4 Winter Tracy Pictures",
"zzz =2010.0 Winter Tracy Pictures",
"zzz =2010.1 Spring Tracy Pictures",
"zzz =2010.2 Summer Tracy Pictures",
"zzz =2010.3 Fall Tracy Pictures",
"zzz =2011.0 Winter Tracy Pictures",
"zzz =2011.1 Spring Tracy Pictures",
"zzz =2011.2 Summer Tracy Pictures",
"zzz =2011.3 Fall Tracy Pictures",
"zzz =2011.4 Winter Tracy Pictures",
"zzz =2012.0 Winter Tracy Pictures",
"zzz =2012.1 Spring Tracy Pictures",
"zzz =2012.2 Summer Tracy Pictures",
"zzz =2012.3 Fall Tracy Pictures",
"zzz =2012.4 Winter Tracy Pictures",
"zzz =2013.0 Winter Tracy Pictures",
"zzz =2013.1 Spring Tracy Pictures",
"zzz =2013.2 Summer Tracy Pictures",
"zzz =2013.3 Fall Tracy Pictures",
"zzz =2013.4 Winter Tracy Pictures",
"zzz =2014.0 Winter Tracy Pictures",
"zzz =2014.1 Spring Tracy Pictures",
"zzz =2014.2 Summer Tracy Pictures",
"zzz =2014.3 Fall Tracy Pictures",
"zzz =2014.4 Winter Tracy Pictures",
"zzz =2015.0 Winter Tracy Pictures"
]
}
}
}