This commit is contained in:
2023-07-20 21:34:08 -07:00
parent 4de1468f51
commit 7733ac1328
4 changed files with 55 additions and 15 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Globalization;
namespace View_by_Distance.Shared.Models.Stateless.Methods;
@ -407,7 +408,10 @@ internal abstract class GenealogicalDataCommunication
List<string> lines = new();
List<long> distinct = new();
List<string> individualsLines;
DateTime dateTime = new(ticks);
Models.PersonBirthday personBirthday;
Calendar calendar = new CultureInfo("en-US").Calendar;
string weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
lines.AddRange(headerLines);
foreach (Models.PersonContainer personContainer in personContainers)
{
@ -468,7 +472,7 @@ internal abstract class GenealogicalDataCommunication
for (int i = 0; i < familyGroupLines.Count; i++)
lines.AddRange(familyGroupLines[i]);
lines.AddRange(footerLines);
File.WriteAllLines(Path.Combine(a2PeopleContentDirectory, $"{ticks}.ged"), lines);
File.WriteAllLines(Path.Combine(a2PeopleContentDirectory, $"{dateTime.Year}-ged", $"{dateTime.Year}-Week-{weekOfYear}", $"{ticks}.ged"), lines);
return result;
}

View File

@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
@ -9,7 +10,7 @@ internal abstract class MarkDown
// ...
internal static void WriteFile(string personKeyFormatted, long ticks, Models.PersonName personName, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations, string a2PeopleContentDirectory, ReadOnlyDictionary<string, string> personKeyFormattedToPersonFullName, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection, bool isDefaultName, Models.GenealogicalDataCommunication genealogicalDataCommunication, bool first)
internal static void WriteFile(string personKeyFormatted, long ticks, Models.PersonName personName, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations, string a2PeopleContentDirectory, Calendar calendar, ReadOnlyDictionary<string, string> personKeyFormattedToPersonFullName, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection, bool isDefaultName, Models.GenealogicalDataCommunication genealogicalDataCommunication, bool first)
{
string decade;
string jrOrSr;
@ -22,9 +23,10 @@ internal abstract class MarkDown
const string child = "CHIL";
const string husband = "HUSB";
const string person = "person";
DateTime dateTime = new(ticks);
string fullName = PersonName.GetFullName(personName);
List<GenealogicalDataCommunicationRelation>? relations;
string now = DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
string now = dateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
string lowerHyphenFullName = $"{Regex.Replace(fullName.ToLower(), "[^a-z0-9-]", "-")}";
string code = IPersonBirthday.GetHour(genealogicalDataCommunication.Death is null, genealogicalDataCommunication.Sex).ToString("00");
List<string> lines = new()
@ -143,7 +145,8 @@ internal abstract class MarkDown
if (hasRelation)
lines.Add(string.Empty);
string text = string.Join(Environment.NewLine, lines);
string directory = Path.Combine(a2PeopleContentDirectory, $"content-{ticks}", person, personKeyFormatted[..3]);
string weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
string directory = Path.Combine(a2PeopleContentDirectory, $"{dateTime.Year}-Markdown", $"{dateTime.Year}-Week-{weekOfYear}", ticks.ToString(), person, personKeyFormatted[..3]);
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
_ = IPath.WriteAllText(Path.Combine(directory, $"{lowerHyphenFullName}.md"), text, updateDateWhenMatches: false, compareBeforeWrite: true);

View File

@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Globalization;
namespace View_by_Distance.Shared.Models.Stateless.Methods;
@ -400,6 +401,7 @@ internal abstract class PersonContainer
bool verify = true;
const int zero = 0;
string personKeyFormatted;
Calendar calendar = new CultureInfo("en-US").Calendar;
Models.GenealogicalDataCommunication genealogicalDataCommunication;
GenealogicalDataCommunicationLines? genealogicalDataCommunicationLines;
ReadOnlyDictionary<string, string> personKeyFormattedToPersonFullName = GetPersonKeyFormattedToPersonFullName(personBirthdayFormat, personContainers);
@ -429,7 +431,7 @@ internal abstract class PersonContainer
if (genealogicalDataCommunication.Death is null && personContainer.PersonDirectory.Status == 'D' || genealogicalDataCommunication.Death is not null && personContainer.PersonDirectory.Status == 'A')
continue;
GenealogicalDataCommunication.WriteFile(personKeyFormatted, personContainer.Person.Name, personContainer.GenealogicalDataCommunicationRelationIndividualsLines, isDefaultName, directory, genealogicalDataCommunication, verify, first.Value);
MarkDown.WriteFile(personKeyFormatted, ticks, personContainer.Person.Name, genealogicalDataCommunicationRelations, a2PeopleContentDirectory, personKeyFormattedToPersonFullName, familyIndexToCollection, isDefaultName, genealogicalDataCommunication, first.Value);
MarkDown.WriteFile(personKeyFormatted, ticks, personContainer.Person.Name, genealogicalDataCommunicationRelations, a2PeopleContentDirectory, calendar, personKeyFormattedToPersonFullName, familyIndexToCollection, isDefaultName, genealogicalDataCommunication, first.Value);
}
}