Remove Person Require People File,
PersonContainer and bug fix for GetRightPadded
This commit is contained in:
@ -9,24 +9,7 @@ namespace View_by_Distance.Instance.Models;
|
||||
internal class A2_People
|
||||
{
|
||||
|
||||
private readonly Serilog.ILogger? _Log;
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||
|
||||
internal A2_People(Configuration configuration)
|
||||
{
|
||||
_Configuration = configuration;
|
||||
_Log = Serilog.Log.ForContext<A2_People>();
|
||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void WriteAllText(Property.Models.Configuration configuration, string outputResolution, List<G2_Identify> identifiedCollection)
|
||||
internal static void WriteAllText(Property.Models.Configuration configuration, string outputResolution, List<G2_Identify> identifiedCollection)
|
||||
{
|
||||
string key;
|
||||
string json;
|
||||
@ -35,6 +18,7 @@ internal class A2_People
|
||||
string[] segments;
|
||||
string directoryFullName;
|
||||
Dictionary<string, List<G2_Identify>> keyValuePairs = new();
|
||||
JsonSerializerOptions writeIndentedJsonSerializerOptions = new() { WriteIndented = true };
|
||||
string hPeopleCollectionDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(A2_People), "[]");
|
||||
string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(Property.Models.A_Property), "{}");
|
||||
foreach (G2_Identify identified in identifiedCollection)
|
||||
@ -54,23 +38,23 @@ internal class A2_People
|
||||
if (!Directory.Exists(directoryFullName))
|
||||
_ = Directory.CreateDirectory(directoryFullName);
|
||||
jsonFile = Path.Combine(directoryFullName, $"{segments[1]}.json");
|
||||
json = JsonSerializer.Serialize(keyValuePair.Value, _WriteIndentedJsonSerializerOptions);
|
||||
json = JsonSerializer.Serialize(keyValuePair.Value, writeIndentedJsonSerializerOptions);
|
||||
if (!Shared.Models.Stateless.Methods.IPath.WriteAllText(jsonFile, json, updateDateWhenMatches: true, compareBeforeWrite: true))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
internal Person[] GetPeople(Property.Models.Configuration configuration)
|
||||
internal static List<PersonContainer> GetPersonContainers(Configuration configuration, Property.Models.Configuration propertyConfiguration)
|
||||
{
|
||||
Person[] results;
|
||||
string rootDirectory = _Configuration.PropertyConfiguration.RootDirectory;
|
||||
string peopleRootDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(A2_People));
|
||||
List<PersonContainer> results;
|
||||
string rootDirectory = configuration.PropertyConfiguration.RootDirectory;
|
||||
string peopleRootDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(propertyConfiguration, nameof(A2_People));
|
||||
string? rootResultsDirectory = Path.GetDirectoryName(Path.GetDirectoryName(peopleRootDirectory));
|
||||
if (rootResultsDirectory is null)
|
||||
throw new Exception();
|
||||
Storage storage = new(rootDirectory, rootResultsDirectory, peopleRootDirectory);
|
||||
results = Shared.Models.Stateless.Methods.IPerson.GetPeople(storage, _Configuration.PersonBirthdayFirstYear, _Configuration.PersonBirthdayFormat, _Configuration.PersonKeyFormat, _Configuration.PersonRequirePeopleFile);
|
||||
return results.ToArray();
|
||||
results = Shared.Models.Stateless.Methods.IPersonContainer.GetPersonContainers(storage, configuration.PersonBirthdayFormat);
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user