Untis-API Optimierung.
This commit is contained in:
@@ -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', ' ');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user