Person Require People File
This commit is contained in:
@ -10,10 +10,10 @@ public interface IPerson
|
||||
static Dictionary<DateTime, string[]> Split(int personBirthdayFirstYear, string personKeyFormat, string knownPeopleFile) =>
|
||||
Person.Split(personBirthdayFirstYear, personKeyFormat, knownPeopleFile);
|
||||
|
||||
Models.Person[] TestStatic_GetPeople(Properties.IStorage storage, int personBirthdayFirstYear, string personBirthdayFormat, string personKeyFormat) =>
|
||||
GetPeople(storage, personBirthdayFirstYear, personBirthdayFormat, personKeyFormat);
|
||||
static Models.Person[] GetPeople(Properties.IStorage storage, int personBirthdayFirstYear, string personBirthdayFormat, string personKeyFormat) =>
|
||||
Person.GetPeople(storage, personBirthdayFirstYear, personBirthdayFormat, personKeyFormat);
|
||||
Models.Person[] TestStatic_GetPeople(Properties.IStorage storage, int personBirthdayFirstYear, string personBirthdayFormat, string personKeyFormat, bool personRequirePeopleFile) =>
|
||||
GetPeople(storage, personBirthdayFirstYear, personBirthdayFormat, personKeyFormat, personRequirePeopleFile);
|
||||
static Models.Person[] GetPeople(Properties.IStorage storage, int personBirthdayFirstYear, string personBirthdayFormat, string personKeyFormat, bool personRequirePeopleFile) =>
|
||||
Person.GetPeople(storage, personBirthdayFirstYear, personBirthdayFormat, personKeyFormat, personRequirePeopleFile);
|
||||
|
||||
void TestStatic_SavePerson(Properties.IStorage storage, string personBirthdayFormat, Models.Person person) =>
|
||||
SavePerson(storage, personBirthdayFormat, person);
|
||||
|
@ -196,7 +196,7 @@ internal abstract class Person
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static Models.Person[] GetPeople(Properties.IStorage storage, int personBirthdayFirstYear, string personBirthdayFormat, string personKeyFormat)
|
||||
internal static Models.Person[] GetPeople(Properties.IStorage storage, int personBirthdayFirstYear, string personBirthdayFormat, string personKeyFormat, bool personRequirePeopleFile)
|
||||
{
|
||||
List<Models.Person> results = new();
|
||||
string json;
|
||||
@ -210,18 +210,15 @@ internal abstract class Person
|
||||
if (!Directory.Exists(peopleSingletonDirectory))
|
||||
_ = Directory.CreateDirectory(peopleSingletonDirectory);
|
||||
if (!Directory.Exists(peopleContentDirectory))
|
||||
localKnownPeopleFile = string.Empty;
|
||||
else
|
||||
{
|
||||
files = Directory.GetFiles(peopleContentDirectory, "*People*.txt", SearchOption.TopDirectoryOnly);
|
||||
if (files.Any())
|
||||
localKnownPeopleFile = files[0];
|
||||
else
|
||||
localKnownPeopleFile = string.Empty;
|
||||
}
|
||||
files = Directory.GetFiles(peopleSingletonDirectory, "*.json", SearchOption.TopDirectoryOnly);
|
||||
if (!files.Any() && string.IsNullOrEmpty(localKnownPeopleFile))
|
||||
_ = Directory.CreateDirectory(peopleContentDirectory);
|
||||
files = Directory.GetFiles(peopleContentDirectory, "*People*.txt", SearchOption.TopDirectoryOnly);
|
||||
if (!files.Any() && personRequirePeopleFile)
|
||||
throw new Exception("Copy \"KnownPeople.txt\" file from server!");
|
||||
if (files.Any())
|
||||
localKnownPeopleFile = files[0];
|
||||
else
|
||||
localKnownPeopleFile = string.Empty;
|
||||
files = Directory.GetFiles(peopleSingletonDirectory, "*.json", SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
fileInfo = new(file);
|
||||
|
Reference in New Issue
Block a user