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;
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);