|
|
|
@@ -1,6 +1,6 @@
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Text.Json;
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
|
|
using System.Net.Http.Json;
|
|
|
|
using Microsoft.Net.Http.Headers;
|
|
|
|
using Microsoft.Net.Http.Headers;
|
|
|
|
using ModeusSchedule.Abstractions;
|
|
|
|
using ModeusSchedule.Abstractions;
|
|
|
|
using ModeusSchedule.Abstractions.DTO;
|
|
|
|
using ModeusSchedule.Abstractions.DTO;
|
|
|
|
@@ -38,11 +38,10 @@ public class ModeusHttpClient
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<string?> GetScheduleAsync(ModeusScheduleRequest msr)
|
|
|
|
public async Task<string?> GetScheduleAsync(ModeusScheduleRequest msr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var request = new HttpRequestMessage(HttpMethod.Post,
|
|
|
|
using var request = new HttpRequestMessage(HttpMethod.Post,
|
|
|
|
$"schedule-calendar-v2/api/calendar/events/search?tz={_configuration["TZ"]!}");
|
|
|
|
$"schedule-calendar-v2/api/calendar/events/search?tz={_configuration["TZ"]!}");
|
|
|
|
request.Content = new StringContent(JsonSerializer.Serialize(msr, GlobalConsts.JsonSerializerOptions),
|
|
|
|
request.Content = JsonContent.Create(msr, options: GlobalConsts.JsonSerializerOptions);
|
|
|
|
Encoding.UTF8, "application/json");
|
|
|
|
using var response = await _httpClient.SendAsync(request);
|
|
|
|
var response = await _httpClient.SendAsync(request);
|
|
|
|
|
|
|
|
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogErrorHere($"Неуспешный статус при получении расписания: {response.StatusCode}, Request: {JsonSerializer.Serialize(msr, GlobalConsts.JsonSerializerOptions)}");
|
|
|
|
_logger.LogErrorHere($"Неуспешный статус при получении расписания: {response.StatusCode}, Request: {JsonSerializer.Serialize(msr, GlobalConsts.JsonSerializerOptions)}");
|
|
|
|
@@ -53,18 +52,20 @@ public class ModeusHttpClient
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<List<Attendees>> GetAttendeesAsync(Guid eventId)
|
|
|
|
public async Task<List<Attendees>> GetAttendeesAsync(Guid eventId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var request = new HttpRequestMessage(HttpMethod.Get,
|
|
|
|
using var request = new HttpRequestMessage(HttpMethod.Get,
|
|
|
|
$"schedule-calendar-v2/api/calendar/events/{eventId}/attendees");
|
|
|
|
$"schedule-calendar-v2/api/calendar/events/{eventId}/attendees");
|
|
|
|
var response = await _httpClient.SendAsync(request);
|
|
|
|
using var response = await _httpClient.SendAsync(request);
|
|
|
|
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogErrorHere($"Неуспешный статус при получении расписания: {response.StatusCode}, eventId: {eventId}");
|
|
|
|
_logger.LogErrorHere($"Неуспешный статус при получении расписания: {response.StatusCode}, eventId: {eventId}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Attendees>? attendees;
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
attendees = Attendees.FromJson(await response.Content.ReadAsStringAsync());
|
|
|
|
await using var contentStream = await response.Content.ReadAsStreamAsync();
|
|
|
|
return attendees;
|
|
|
|
var attendees = await JsonSerializer.DeserializeAsync<List<Attendees>>(
|
|
|
|
|
|
|
|
contentStream,
|
|
|
|
|
|
|
|
GlobalConsts.JsonSerializerOptions);
|
|
|
|
|
|
|
|
return attendees ?? [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -78,9 +79,7 @@ public class ModeusHttpClient
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using var request = new HttpRequestMessage(HttpMethod.Post,
|
|
|
|
using var request = new HttpRequestMessage(HttpMethod.Post,
|
|
|
|
$"schedule-calendar-v2/api/people/persons/search");
|
|
|
|
$"schedule-calendar-v2/api/people/persons/search");
|
|
|
|
request.Content = new StringContent(
|
|
|
|
request.Content = JsonContent.Create(modeusSearchPersonRequest, options: GlobalConsts.JsonSerializerOptions);
|
|
|
|
JsonSerializer.Serialize(modeusSearchPersonRequest, GlobalConsts.JsonSerializerOptions),
|
|
|
|
|
|
|
|
Encoding.UTF8, "application/json");
|
|
|
|
|
|
|
|
var stopwatch = Stopwatch.StartNew();
|
|
|
|
var stopwatch = Stopwatch.StartNew();
|
|
|
|
using var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
|
|
|
|
using var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
|
|
|
|
var requestMs = stopwatch.ElapsedMilliseconds;
|
|
|
|
var requestMs = stopwatch.ElapsedMilliseconds;
|
|
|
|
@@ -113,11 +112,9 @@ public class ModeusHttpClient
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<string?> SearchRoomsAsync(RoomSearchRequest requestDto)
|
|
|
|
public async Task<string?> SearchRoomsAsync(RoomSearchRequest requestDto)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var request = new HttpRequestMessage(HttpMethod.Post, "schedule-calendar-v2/api/campus/rooms/search");
|
|
|
|
using var request = new HttpRequestMessage(HttpMethod.Post, "schedule-calendar-v2/api/campus/rooms/search");
|
|
|
|
request.Content =
|
|
|
|
request.Content = JsonContent.Create(requestDto, options: GlobalConsts.JsonSerializerOptions);
|
|
|
|
new StringContent(JsonSerializer.Serialize(requestDto, GlobalConsts.JsonSerializerOptions),
|
|
|
|
using var response = await _httpClient.SendAsync(request);
|
|
|
|
Encoding.UTF8, "application/json");
|
|
|
|
|
|
|
|
var response = await _httpClient.SendAsync(request);
|
|
|
|
|
|
|
|
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogErrorHere($"Неуспешный статус при получении расписания: {response.StatusCode}, Request: {JsonSerializer.Serialize(requestDto, GlobalConsts.JsonSerializerOptions)}");
|
|
|
|
_logger.LogErrorHere($"Неуспешный статус при получении расписания: {response.StatusCode}, Request: {JsonSerializer.Serialize(requestDto, GlobalConsts.JsonSerializerOptions)}");
|
|
|
|
|