Untis-API Optimierung.

This commit is contained in:
2026-08-24 22:33:30 +02:00
parent 1db16f8b69
commit 17475a781f
9 changed files with 109 additions and 53 deletions
@@ -13,6 +13,7 @@ using LehrerApp.Desktop.Views.Shared;
using LehrerApp.Desktop.Views.Students;
using LehrerApp.Desktop.Views.Workload;
using Microsoft.Extensions.DependencyInjection;
using System.Globalization;
using System.Text;
namespace LehrerApp.Desktop.Views.Groups;
@@ -174,7 +175,7 @@ public partial class GroupDetailView : UserControl
var values = new[]
{
student.LongName ?? student.Name, student.ForeName, student.Gender,
student.BirthDate?.ToString() ?? student.BirthDateRaw, student.ClassName,
FormatBirthDate(student), student.ClassName,
student.ExternKey.ToString(), student.Address.Email, student.Address.Mobile,
student.Address.Phone, student.Address.City, student.Address.PostCode, student.Address.Street,
};
@@ -183,6 +184,17 @@ public partial class GroupDetailView : UserControl
return new ImportFile("webuntis-students.csv", Encoding.UTF8.GetBytes(builder.ToString()));
}
private static string? FormatBirthDate(UntisStudentDto student)
{
if (student.BirthDate is not { } normalizedDate) return student.BirthDateRaw;
var value = normalizedDate.ToString("D8", CultureInfo.InvariantCulture);
return DateOnly.TryParseExact(value, "yyyyMMdd", CultureInfo.InvariantCulture,
DateTimeStyles.None, out var date)
? date.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture)
: student.BirthDateRaw;
}
private static string SafeTsv(string? value) => (value ?? "").Replace('\t', ' ')
.Replace('\r', ' ').Replace('\n', ' ');