From 26526e14bd93cc7110e557e2e975103168ad1054 Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Wed, 17 Sep 2025 23:32:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BF=D0=BE=D0=B4=D1=80=D0=BE?= =?UTF-8?q?=D0=B1=D0=BD=D0=BE=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScheduleDTO.CS | 353 ++++++++++++++++++ .../Controllers/ScheduleController.cs | 5 +- 2 files changed, 356 insertions(+), 2 deletions(-) create mode 100644 SfeduSchedule.Plugin.Abstractions/ScheduleDTO.CS diff --git a/SfeduSchedule.Plugin.Abstractions/ScheduleDTO.CS b/SfeduSchedule.Plugin.Abstractions/ScheduleDTO.CS new file mode 100644 index 0000000..647b5c4 --- /dev/null +++ b/SfeduSchedule.Plugin.Abstractions/ScheduleDTO.CS @@ -0,0 +1,353 @@ +namespace SfeduSchedule.Plugin.Abstractions; + +// Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); +public class Building +{ + public string id { get; set; } + public string name { get; set; } + public string nameShort { get; set; } + public string address { get; set; } + public int displayOrder { get; set; } + public string href { get; set; } +} + +public class Building3 +{ + public string name { get; set; } + public string nameShort { get; set; } + public string address { get; set; } + public string searchableAddress { get; set; } + public int displayOrder { get; set; } + public Links _links { get; set; } + public string id { get; set; } +} + +public class CourseUnitRealization +{ + public string href { get; set; } +} + +public class CourseUnitRealization2 +{ + public string name { get; set; } + public string nameShort { get; set; } + public string prototypeId { get; set; } + public Links _links { get; set; } + public string id { get; set; } +} + +public class CycleRealization +{ + public string href { get; set; } +} + +public class CycleRealization2 +{ + public string name { get; set; } + public string nameShort { get; set; } + public string code { get; set; } + public string courseUnitRealizationNameShort { get; set; } + public Links _links { get; set; } + public string id { get; set; } +} + +public class Duration +{ + public string href { get; set; } +} + +public class Duration2 +{ + public string eventId { get; set; } + public int value { get; set; } + public string timeUnitId { get; set; } + public int minutes { get; set; } + public Links _links { get; set; } +} + +public class Embedded +{ + public List events { get; set; } + + [JsonProperty("course-unit-realizations")] + public List courseunitrealizations { get; set; } + + [JsonProperty("cycle-realizations")] public List cyclerealizations { get; set; } + + [JsonProperty("lesson-realization-teams")] + public List lessonrealizationteams { get; set; } + + [JsonProperty("lesson-realizations")] public List lessonrealizations { get; set; } + + [JsonProperty("event-locations")] public List eventlocations { get; set; } + + public List durations { get; set; } + + [JsonProperty("event-rooms")] public List eventrooms { get; set; } + + public List rooms { get; set; } + public List buildings { get; set; } + + [JsonProperty("event-teams")] public List eventteams { get; set; } + + [JsonProperty("event-organizers")] public List eventorganizers { get; set; } + + [JsonProperty("event-attendees")] public List eventattendees { get; set; } + + public List persons { get; set; } +} + +public class Event +{ + public string name { get; set; } + public string nameShort { get; set; } + public object description { get; set; } + public string typeId { get; set; } + public string formatId { get; set; } + public DateTime start { get; set; } + public DateTime end { get; set; } + public DateTime startsAtLocal { get; set; } + public DateTime endsAtLocal { get; set; } + public DateTime startsAt { get; set; } + public DateTime endsAt { get; set; } + public HoldingStatus holdingStatus { get; set; } + public object repeatedLessonRealization { get; set; } + public List userRoleIds { get; set; } + public string lessonTemplateId { get; set; } + public int __version { get; set; } + public Links _links { get; set; } + public string id { get; set; } +} + +public class Event2 +{ + public string href { get; set; } +} + +public class EventAttendee +{ + public string roleId { get; set; } + public string roleName { get; set; } + public string roleNamePlural { get; set; } + public int roleDisplayOrder { get; set; } + public Links _links { get; set; } + public string id { get; set; } +} + +public class EventLocation +{ + public string eventId { get; set; } + public object customLocation { get; set; } + public Links _links { get; set; } +} + +public class EventOrganizer +{ + public string eventId { get; set; } + public Links _links { get; set; } +} + +public class EventRoom +{ + public Links _links { get; set; } + public string id { get; set; } + public string href { get; set; } +} + +public class EventTeam +{ + public string eventId { get; set; } + public int size { get; set; } + public Links _links { get; set; } +} + +public class Format +{ + public string href { get; set; } +} + +public class Grid +{ + public string href { get; set; } +} + +public class HoldingStatus +{ + public string id { get; set; } + public string name { get; set; } + public DateTime? audModifiedAt { get; set; } + public string audModifiedBy { get; set; } + public bool? audModifiedBySystem { get; set; } +} + +public class HoldingStatusModifiedBy +{ + public string href { get; set; } +} + +public class LessonRealization +{ + public string href { get; set; } +} + +public class LessonRealization2 +{ + public string name { get; set; } + public string nameShort { get; set; } + public string prototypeId { get; set; } + public int ordinal { get; set; } + public Links _links { get; set; } + public string id { get; set; } +} + +public class LessonRealizationTeam +{ + public string href { get; set; } +} + +public class LessonRealizationTeam2 +{ + public string name { get; set; } + public string cycleRealizationId { get; set; } + public Links _links { get; set; } + public string id { get; set; } +} + +public class LessonRealizationTemplate +{ + public string href { get; set; } +} + +public class Links +{ + public Self self { get; set; } + public Type type { get; set; } + public Format format { get; set; } + + [JsonProperty("time-zone")] public TimeZone timezone { get; set; } + + public Grid grid { get; set; } + + [JsonProperty("course-unit-realization")] + public CourseUnitRealization courseunitrealization { get; set; } + + [JsonProperty("cycle-realization")] public CycleRealization cyclerealization { get; set; } + + [JsonProperty("lesson-realization")] public LessonRealization lessonrealization { get; set; } + + [JsonProperty("lesson-realization-team")] + public LessonRealizationTeam lessonrealizationteam { get; set; } + + [JsonProperty("lesson-realization-template")] + public LessonRealizationTemplate lessonrealizationtemplate { get; set; } + + public Location location { get; set; } + public Duration duration { get; set; } + public Team team { get; set; } + public Organizers organizers { get; set; } + + [JsonProperty("holding-status-modified-by")] + public HoldingStatusModifiedBy holdingstatusmodifiedby { get; set; } + + public Event @event { get; set; } + + [JsonProperty("event-attendees")] public object eventattendees { get; set; } + + public Person person { get; set; } + + [JsonProperty("planning-period")] public PlanningPeriod planningperiod { get; set; } + + [JsonProperty("event-rooms")] public EventRooms eventrooms { get; set; } + + [JsonProperty("time-unit")] public TimeUnit timeunit { get; set; } + + public Room room { get; set; } + public Building building { get; set; } +} + +public class Location +{ + public string href { get; set; } +} + +public class Organizers +{ + public string href { get; set; } +} + +public class Page +{ + public int size { get; set; } + public int totalElements { get; set; } + public int totalPages { get; set; } + public int number { get; set; } +} + +public class Person +{ + public string href { get; set; } +} + +public class Person2 +{ + public string lastName { get; set; } + public string firstName { get; set; } + public string middleName { get; set; } + public string fullName { get; set; } + public Links _links { get; set; } + public string id { get; set; } +} + +public class PlanningPeriod +{ + public string href { get; set; } +} + +public class Room +{ + public string href { get; set; } +} + +public class Room2 +{ + public string name { get; set; } + public string nameShort { get; set; } + public Building building { get; set; } + public bool projectorAvailable { get; set; } + public int totalCapacity { get; set; } + public int workingCapacity { get; set; } + public object deletedAtUtc { get; set; } + public Links _links { get; set; } + public string id { get; set; } +} + +public class Root +{ + public Embedded _embedded { get; set; } + public Page page { get; set; } +} + +public class Self +{ + public string href { get; set; } +} + +public class Team +{ + public string href { get; set; } +} + +public class TimeUnit +{ + public string href { get; set; } +} + +public class TimeZone +{ + public string href { get; set; } +} + +public class Type +{ + public string href { get; set; } +} \ No newline at end of file diff --git a/SfeduSchedule/Controllers/ScheduleController.cs b/SfeduSchedule/Controllers/ScheduleController.cs index cde5b31..94ef03f 100644 --- a/SfeduSchedule/Controllers/ScheduleController.cs +++ b/SfeduSchedule/Controllers/ScheduleController.cs @@ -1,4 +1,5 @@ using System.Net; +using System.Text.Json; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.RateLimiting; @@ -29,7 +30,7 @@ namespace SfeduSchedule.Controllers } catch (HttpRequestException e) { - logger.LogError("Ошибка при получении расписания\n\n" + e.Message); + logger.LogError("Ошибка при получении расписания\n\n" + e.Message + "\n\n" + e.StackTrace + "\n\n JSON: " + JsonSerializer.Serialize(request)); return StatusCode((int)(e.StatusCode ?? HttpStatusCode.InternalServerError), e.Message); } return Ok(schedule); @@ -53,7 +54,7 @@ namespace SfeduSchedule.Controllers } catch (HttpRequestException e) { - logger.LogError("Ошибка при поиске аудиторий\n\n" + e.Message); + logger.LogError("Ошибка при поиске аудиторий\n\n" + e.Message + "\n\n" + e.StackTrace + "\n\n JSON: " + JsonSerializer.Serialize(request)); return StatusCode((int)(e.StatusCode ?? HttpStatusCode.InternalServerError), e.Message); } return Ok(rooms);