From 03ee564dc30a561890c53ed964f236be8d809fa6 Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Thu, 25 Sep 2025 18:23:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SfeduSchedule/Services/ModeusService.cs | 33 ++++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/SfeduSchedule/Services/ModeusService.cs b/SfeduSchedule/Services/ModeusService.cs index e785683..5a8a463 100644 --- a/SfeduSchedule/Services/ModeusService.cs +++ b/SfeduSchedule/Services/ModeusService.cs @@ -25,8 +25,10 @@ namespace SfeduSchedule.Services public async Task GetScheduleAsync(ModeusScheduleRequest msr) { - var request = new HttpRequestMessage(HttpMethod.Post, $"schedule-calendar-v2/api/calendar/events/search?tz={_configuration["TZ"]!}"); - request.Content = new StringContent(JsonSerializer.Serialize(msr, GlobalVariables.jsonSerializerOptions), System.Text.Encoding.UTF8, "application/json"); + var request = new HttpRequestMessage(HttpMethod.Post, + $"schedule-calendar-v2/api/calendar/events/search?tz={_configuration["TZ"]!}"); + request.Content = new StringContent(JsonSerializer.Serialize(msr, GlobalVariables.jsonSerializerOptions), + System.Text.Encoding.UTF8, "application/json"); var response = await _httpClient.SendAsync(request); _logger.LogInformation("GetScheduleAsync: Ответ получен: {StatusCode}", response.StatusCode); response.EnsureSuccessStatusCode(); @@ -36,7 +38,9 @@ namespace SfeduSchedule.Services public async Task SearchRoomsAsync(RoomSearchRequest requestDto) { var request = new HttpRequestMessage(HttpMethod.Post, $"schedule-calendar-v2/api/campus/rooms/search"); - request.Content = new StringContent(JsonSerializer.Serialize(requestDto, GlobalVariables.jsonSerializerOptions), System.Text.Encoding.UTF8, "application/json"); + request.Content = + new StringContent(JsonSerializer.Serialize(requestDto, GlobalVariables.jsonSerializerOptions), + System.Text.Encoding.UTF8, "application/json"); var response = await _httpClient.SendAsync(request); _logger.LogInformation("SearchRoomsAsync: Ответ получен: {StatusCode}", response.StatusCode); response.EnsureSuccessStatusCode(); @@ -71,13 +75,15 @@ namespace SfeduSchedule.Services } catch { - _logger.LogWarning("GetGuidAsync: Не удалось получить идентификатор пользователя, {FullName}, json: {Json}", fullName, json); + _logger.LogWarning( + "GetGuidAsync: Не удалось получить идентификатор пользователя, {FullName}, json: {Json}", fullName, + json); return null; } return personId; } - + public async Task GetIcsAsync(ModeusScheduleRequest msr) { var schedule = await GetScheduleAsync(msr); @@ -103,11 +109,14 @@ namespace SfeduSchedule.Services if (scheduleJson == null) _logger.LogError("GetIcsAsync: scheduleJson is null. Schedule: {Schedule}", schedule); else if (scheduleJson.Embedded == null) - _logger.LogError("GetIcsAsync: scheduleJson.Embedded is null. scheduleJson: {@scheduleJson}", scheduleJson); + _logger.LogError("GetIcsAsync: scheduleJson.Embedded is null. scheduleJson: {@scheduleJson}", + scheduleJson); else if (scheduleJson.Embedded.Events == null) - _logger.LogError("GetIcsAsync: scheduleJson.Embedded.Events is null. Embedded: {@Embedded}", scheduleJson.Embedded); + _logger.LogError("GetIcsAsync: scheduleJson.Embedded.Events is null. Embedded: {@Embedded}", + scheduleJson.Embedded); else - _logger.LogWarning("GetIcsAsync: scheduleJson.Embedded.Events is empty. Embedded: {@Embedded}", scheduleJson.Embedded); + _logger.LogWarning("GetIcsAsync: scheduleJson.Embedded.Events is empty. Embedded: {@Embedded}", + scheduleJson.Embedded); return null; } @@ -124,12 +133,12 @@ namespace SfeduSchedule.Services End = new CalDateTime(e.EndsAtLocal, _configuration["TZ"]!), }); } + var serializer = new CalendarSerializer(); var serializedCalendar = serializer.SerializeToString(calendar); - _logger.LogInformation("GetIcsAsync: Serialized calendar created. Length: {Length}", serializedCalendar?.Length ?? 0); + _logger.LogInformation("GetIcsAsync: Serialized calendar created. Length: {Length}", + serializedCalendar?.Length ?? 0); return serializedCalendar; - } - } -} +} \ No newline at end of file