Небольшой рефактор
This commit is contained in:
@@ -25,8 +25,10 @@ namespace SfeduSchedule.Services
|
||||
|
||||
public async Task<string?> 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<string?> 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,7 +75,9 @@ namespace SfeduSchedule.Services
|
||||
}
|
||||
catch
|
||||
{
|
||||
_logger.LogWarning("GetGuidAsync: Не удалось получить идентификатор пользователя, {FullName}, json: {Json}", fullName, json);
|
||||
_logger.LogWarning(
|
||||
"GetGuidAsync: Не удалось получить идентификатор пользователя, {FullName}, json: {Json}", fullName,
|
||||
json);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user