From f043253cf2866e30c8304ea60ff0ddb589132ae9 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Mon, 30 Oct 2023 12:13:38 +0500 Subject: [PATCH 01/12] =?UTF-8?q?1.=20=D0=A2=D0=B8=D0=BF=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D1=81?= =?UTF-8?q?=D0=BA=D0=B8=D1=85=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2?= =?UTF-8?q?=20signal-R=202.=20=D0=94=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D1=81=D0=BA=D0=B8=D1=85=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20signal-R=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D0=BF=D0=BE=D0=BC=D0=BE=D1=89=D0=B8=20SignalRSw?= =?UTF-8?q?aggerGen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/AsbCloudWebApi.csproj | 3 +- .../Controllers/DrillTestController.cs | 8 ++--- .../ProcessMaps/ProcessMapBaseController.cs | 7 ++-- .../ProcessMapWellDrillingController.cs | 3 +- .../ProcessMapWellReamController.cs | 3 +- .../Controllers/ReportController.cs | 12 +++++-- .../ApiExplorerGroupPerVersionConvention.cs | 13 +++++++ AsbCloudWebApi/DependencyInjection.cs | 8 +++++ AsbCloudWebApi/SignalR/BaseHub.cs | 8 ++--- .../SignalR/Clients/INotificationHubClient.cs | 22 ++++++++++++ .../SignalR/Clients/IReportHubClient.cs | 21 ++++++++++++ .../SignalR/Clients/ITelemetryHubClient.cs | 34 +++++++++++++++++++ .../SignalR/Clients/IWellInfoHubClient.cs | 22 ++++++++++++ AsbCloudWebApi/SignalR/IReportHubClient.cs | 7 ---- AsbCloudWebApi/SignalR/NotificationHub.cs | 3 +- AsbCloudWebApi/SignalR/ReportsHub.cs | 29 ++++++++++++---- .../SignalR/Services/NotificationPublisher.cs | 9 +++-- AsbCloudWebApi/SignalR/TelemetryHub.cs | 5 +-- AsbCloudWebApi/SignalR/WellInfoHub.cs | 11 +++--- AsbCloudWebApi/Startup.cs | 6 ++++ 20 files changed, 191 insertions(+), 43 deletions(-) create mode 100644 AsbCloudWebApi/Conventions/ApiExplorerGroupPerVersionConvention.cs create mode 100644 AsbCloudWebApi/SignalR/Clients/INotificationHubClient.cs create mode 100644 AsbCloudWebApi/SignalR/Clients/IReportHubClient.cs create mode 100644 AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs create mode 100644 AsbCloudWebApi/SignalR/Clients/IWellInfoHubClient.cs delete mode 100644 AsbCloudWebApi/SignalR/IReportHubClient.cs diff --git a/AsbCloudWebApi/AsbCloudWebApi.csproj b/AsbCloudWebApi/AsbCloudWebApi.csproj index 5f231625..0d8f4806 100644 --- a/AsbCloudWebApi/AsbCloudWebApi.csproj +++ b/AsbCloudWebApi/AsbCloudWebApi.csproj @@ -2,7 +2,7 @@ net6.0 - true + true true $(NoWarn);1591 80899ceb-210f-4f19-ac56-aa90a5d666d4 @@ -14,6 +14,7 @@ + diff --git a/AsbCloudWebApi/Controllers/DrillTestController.cs b/AsbCloudWebApi/Controllers/DrillTestController.cs index bda32d6e..2d9585dc 100644 --- a/AsbCloudWebApi/Controllers/DrillTestController.cs +++ b/AsbCloudWebApi/Controllers/DrillTestController.cs @@ -5,6 +5,7 @@ using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; using AsbCloudWebApi.SignalR; +using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -28,16 +29,15 @@ public class DrillTestController : ControllerBase private readonly IDrillTestRepository drillTestRepository; private readonly IWellService wellService; private readonly ITelemetryService telemetryService; - private readonly IHubContext telemetryHubContext; + private readonly IHubContext telemetryHubContext; - public string SignalRMethodGetDataName { get; protected set; } = "ReceiveDrilltestData"; public DrillTestController( IDrillTestReportService drillTestReportService, IDrillTestRepository drillTestRepository, IWellService wellService, ITelemetryService telemetryService, - IHubContext telemetryHubContext) + IHubContext telemetryHubContext) { this.drillTestReportService = drillTestReportService; this.drillTestRepository = drillTestRepository; @@ -71,7 +71,7 @@ public class DrillTestController : ControllerBase _ = Task.Run(async () => { var clients = telemetryHubContext.Clients.Group($"well_{idWell}"); - await clients.SendAsync(SignalRMethodGetDataName, dto); + await clients.ReceiveDrilltestData(dto, token); }, CancellationToken.None); return Ok(); diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs index 9bb52f33..e512aca2 100644 --- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs @@ -9,6 +9,7 @@ using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; using AsbCloudWebApi.SignalR; +using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -25,7 +26,7 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps; public abstract class ProcessMapBaseController : ControllerBase where T : ProcessMapPlanBaseDto { - private readonly IHubContext telemetryHubContext; + private readonly IHubContext telemetryHubContext; private readonly ITelemetryService telemetryService; private readonly IWellService wellService; private readonly IUserRepository userRepository; @@ -36,7 +37,7 @@ public abstract class ProcessMapBaseController : ControllerBase IProcessMapPlanRepository repository, IUserRepository userRepository, ICrudRepository wellSectionRepository, - IHubContext telemetryHubContext, + IHubContext telemetryHubContext, ITelemetryService telemetryService) { this.wellService = wellService; @@ -204,7 +205,7 @@ public abstract class ProcessMapBaseController : ControllerBase await telemetryHubContext.Clients .Group($"{SignalRMethod}_{idWell}") - .SendAsync("UpdateProcessMap", dtos, cancellationToken); + .UpdateProcessMap(dtos, cancellationToken); } private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken) diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs index 89963cfb..9f6812e6 100644 --- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs @@ -10,6 +10,7 @@ using AsbCloudApp.Services; using AsbCloudApp.Services.ProcessMaps; using AsbCloudApp.Services.ProcessMaps.WellDrilling; using AsbCloudWebApi.SignalR; +using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; @@ -34,7 +35,7 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController wellSectionRepository, - IHubContext telemetryHubContext, + IHubContext telemetryHubContext, ITelemetryService telemetryService) : base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService) { diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs index f0f48e74..b54323d2 100644 --- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs @@ -3,6 +3,7 @@ using AsbCloudApp.Data.ProcessMaps; using AsbCloudApp.Repositories; using AsbCloudApp.Services; using AsbCloudWebApi.SignalR; +using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.SignalR; namespace AsbCloudWebApi.Controllers.ProcessMaps; @@ -16,7 +17,7 @@ public class ProcessMapWellReamController : ProcessMapBaseController repository, IUserRepository userRepository, ICrudRepository wellSectionRepository, - IHubContext telemetryHubContext, + IHubContext telemetryHubContext, ITelemetryService telemetryService) : base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService) { diff --git a/AsbCloudWebApi/Controllers/ReportController.cs b/AsbCloudWebApi/Controllers/ReportController.cs index 3386d505..5e7a8fc2 100644 --- a/AsbCloudWebApi/Controllers/ReportController.cs +++ b/AsbCloudWebApi/Controllers/ReportController.cs @@ -8,6 +8,7 @@ using System.ComponentModel.DataAnnotations; using System.Threading; using System.Threading.Tasks; using AsbCloudApp.Requests; +using AsbCloudWebApi.SignalR.Clients; namespace AsbCloudWebApi.Controllers { @@ -57,9 +58,16 @@ namespace AsbCloudWebApi.Controllers return Forbid(); void HandleReportProgressAsync(object progress, string id) => - Task.Run(() => + Task.Run(async() => { - reportsHubContext.Clients.Group($"Report_{id}").SendAsync( + //reportsHubContext.Clients.Group($"Report_{id}") + // .GetReportProgressTest(progress, token); + //.ConfigureAwait(false); + + //await reportsHubContext.Clients.Group($"Report_{id}") + // .GetReportProgress(progress, token); + + await reportsHubContext.Clients.Group($"Report_{id}").SendAsync( nameof(IReportHubClient.GetReportProgress), progress, token diff --git a/AsbCloudWebApi/Conventions/ApiExplorerGroupPerVersionConvention.cs b/AsbCloudWebApi/Conventions/ApiExplorerGroupPerVersionConvention.cs new file mode 100644 index 00000000..69a912cf --- /dev/null +++ b/AsbCloudWebApi/Conventions/ApiExplorerGroupPerVersionConvention.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Mvc.ApplicationModels; +using System.Linq; + +namespace AsbCloudWebApi.Conventions +{ + public class ApiExplorerGroupPerVersionConvention : IControllerModelConvention + { + public void Apply(ControllerModel controller) + { + controller.ApiExplorer.GroupName = "v1"; + } + } +} \ No newline at end of file diff --git a/AsbCloudWebApi/DependencyInjection.cs b/AsbCloudWebApi/DependencyInjection.cs index 998212b2..be2baf9b 100644 --- a/AsbCloudWebApi/DependencyInjection.cs +++ b/AsbCloudWebApi/DependencyInjection.cs @@ -46,6 +46,7 @@ namespace AsbCloudWebApi }); c.SwaggerDoc("v1", new OpenApiInfo { Title = "ASB cloud web api", Version = "v1" }); + c.SwaggerDoc("signalr", new OpenApiInfo { Title = "SignalR client methods", Version = "signalr" }); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Description = @"JWT Authorization header using the Bearer scheme. Enter 'Bearer' [space] and then your token in the text input below. Example: 'Bearer 12345abcdef'", @@ -78,6 +79,13 @@ namespace AsbCloudWebApi var includeControllerXmlComment = true; c.IncludeXmlComments(xmlPath, includeControllerXmlComment); c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "AsbCloudApp.xml"), includeControllerXmlComment); + + c.AddSignalRSwaggerGen((_) => { + _.DisplayInDocument("signalr"); + _.UseHubXmlCommentsSummaryAsTagDescription = true; + _.UseHubXmlCommentsSummaryAsTag = true; + _.UseXmlComments(xmlPath); + }); }); } diff --git a/AsbCloudWebApi/SignalR/BaseHub.cs b/AsbCloudWebApi/SignalR/BaseHub.cs index c351ccc4..1bb151c1 100644 --- a/AsbCloudWebApi/SignalR/BaseHub.cs +++ b/AsbCloudWebApi/SignalR/BaseHub.cs @@ -1,9 +1,10 @@ +using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; namespace AsbCloudWebApi.SignalR; -public abstract class BaseHub : Hub +public abstract class BaseHub : Hub where T : class { public virtual Task AddToGroup(string groupName) => Groups.AddToGroupAsync(Context.ConnectionId, groupName); @@ -12,8 +13,7 @@ public abstract class BaseHub : Hub Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName); } -public abstract class BaseHub : BaseHub - where T : class +public abstract class BaseHub2 : Hub { - + } \ No newline at end of file diff --git a/AsbCloudWebApi/SignalR/Clients/INotificationHubClient.cs b/AsbCloudWebApi/SignalR/Clients/INotificationHubClient.cs new file mode 100644 index 00000000..aae2cb77 --- /dev/null +++ b/AsbCloudWebApi/SignalR/Clients/INotificationHubClient.cs @@ -0,0 +1,22 @@ +using AsbCloudWebApi.SignalR.Messages; +using SignalRSwaggerGen.Attributes; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudWebApi.SignalR.Clients +{ + /// + /// Hub по работе с уведомлениями + /// + [SignalRHub] + public interface INotificationHubClient + { + /// + /// Отправка клиенту сообщения с уведомлением + /// + /// сообщение с уведомлением + /// + /// + Task ReceiveNotifications(NotificationMessage message, CancellationToken token = default); + } +} diff --git a/AsbCloudWebApi/SignalR/Clients/IReportHubClient.cs b/AsbCloudWebApi/SignalR/Clients/IReportHubClient.cs new file mode 100644 index 00000000..6c25d829 --- /dev/null +++ b/AsbCloudWebApi/SignalR/Clients/IReportHubClient.cs @@ -0,0 +1,21 @@ +using SignalRSwaggerGen.Attributes; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudWebApi.SignalR.Clients +{ + /// + /// Hub по работе с отчетами + /// + [SignalRHub] + public interface IReportHubClient + { + /// + /// Отправка клиенту сообщения о статусе формирования отчета + /// + /// статус формирования отчета + /// + /// + Task GetReportProgress(object progress, CancellationToken token); + } +} diff --git a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs new file mode 100644 index 00000000..fa915aa0 --- /dev/null +++ b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs @@ -0,0 +1,34 @@ +using AsbCloudApp.Data; +using AsbCloudApp.Data.SAUB; +using SignalRSwaggerGen.Attributes; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudWebApi.SignalR.Clients +{ + /// + /// Hub по работе с телеметрией + /// + [SignalRHub] + public interface ITelemetryHubClient + { + /// + /// Отправка клиенту уведомления о доставке с панели drill test данных + /// + /// + /// + /// + Task ReceiveDrilltestData(DrillTestDto dto, CancellationToken token = default); + + /// + /// + /// + /// + /// + /// + /// + Task UpdateProcessMap(IEnumerable dtos, CancellationToken token = default); + } +} diff --git a/AsbCloudWebApi/SignalR/Clients/IWellInfoHubClient.cs b/AsbCloudWebApi/SignalR/Clients/IWellInfoHubClient.cs new file mode 100644 index 00000000..a898d207 --- /dev/null +++ b/AsbCloudWebApi/SignalR/Clients/IWellInfoHubClient.cs @@ -0,0 +1,22 @@ +using AsbCloudApp.Data; +using SignalRSwaggerGen.Attributes; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudWebApi.SignalR.Clients +{ + /// + /// Hub по работе с информацией о скважине + /// + [SignalRHub] + public interface IWellInfoHubClient + { + /// + /// Отправка клиенту сообщения об обновлении информации о скважине + /// + /// информация о скважине + /// + /// + Task UpdateWellInfo(object wellInfo, CancellationToken token = default); + } +} diff --git a/AsbCloudWebApi/SignalR/IReportHubClient.cs b/AsbCloudWebApi/SignalR/IReportHubClient.cs deleted file mode 100644 index 4eb9581f..00000000 --- a/AsbCloudWebApi/SignalR/IReportHubClient.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace AsbCloudWebApi.SignalR -{ - public interface IReportHubClient - { - float GetReportProgress(float progress); - } -} diff --git a/AsbCloudWebApi/SignalR/NotificationHub.cs b/AsbCloudWebApi/SignalR/NotificationHub.cs index b85ce74b..4deea974 100644 --- a/AsbCloudWebApi/SignalR/NotificationHub.cs +++ b/AsbCloudWebApi/SignalR/NotificationHub.cs @@ -2,6 +2,7 @@ using System; using System.Threading; using System.Threading.Tasks; using AsbCloudApp.Services.Notifications; +using AsbCloudWebApi.SignalR.Clients; using AsbCloudWebApi.SignalR.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -9,7 +10,7 @@ using Microsoft.AspNetCore.Mvc; namespace AsbCloudWebApi.SignalR; [Authorize] -public class NotificationHub : BaseHub +public class NotificationHub : BaseHub { private readonly ConnectionManagerService connectionManagerService; private readonly NotificationService notificationService; diff --git a/AsbCloudWebApi/SignalR/ReportsHub.cs b/AsbCloudWebApi/SignalR/ReportsHub.cs index 1097c5ef..c4335396 100644 --- a/AsbCloudWebApi/SignalR/ReportsHub.cs +++ b/AsbCloudWebApi/SignalR/ReportsHub.cs @@ -1,5 +1,6 @@ using AsbCloudApp.Data; using AsbCloudInfrastructure.Background; +using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.SignalR; using System.Linq; @@ -10,9 +11,13 @@ namespace AsbCloudWebApi.SignalR { // SignalR manual: // https://docs.microsoft.com/ru-ru/aspnet/core/signalr/introduction?view=aspnetcore-5.0 - + //[SignalRHub] + /// + /// ReportsHub + /// [Authorize] - public class ReportsHub : BaseHub + public class ReportsHub : BaseHub2 + //BaseHub //Hub //BaseHub<> { private readonly BackgroundWorker backgroundWorker; @@ -21,9 +26,15 @@ namespace AsbCloudWebApi.SignalR this.backgroundWorker = backgroundWorker; } - public override async Task AddToGroup(string groupName) + /// + /// Добавление в группу, отправка данных о формировании отчета + /// + /// + /// + public async Task AddToGroup(string groupName) { - await base.AddToGroup(groupName); + //await this.AddToGroup(groupName); + //await this.Groups.AddToGroupAsync(Context.ConnectionId, groupName); var workId = groupName.Replace("Report_", ""); var work = backgroundWorker.WorkStore.RunOnceQueue.FirstOrDefault(work => work.Id == workId); @@ -34,19 +45,25 @@ namespace AsbCloudWebApi.SignalR Progress = 0f, }; - var state = work?.CurrentState; + var state = work?.CurrentState; if (state is not null) { progress.Operation = state.State; progress.Progress = (float)state.Progress; } - await Clients.Group(groupName).SendAsync( nameof(IReportHubClient.GetReportProgress), progress, CancellationToken.None ); + //await Clients.Group(groupName).GetReportProgress(progress, CancellationToken.None); + } + + //public async Task GetReportProgressTest(object obj, CancellationToken token) + //{ + // await Clients.All.GetReportProgressTest(obj, token); + //} } } diff --git a/AsbCloudWebApi/SignalR/Services/NotificationPublisher.cs b/AsbCloudWebApi/SignalR/Services/NotificationPublisher.cs index 1f6f4f67..6799e71d 100644 --- a/AsbCloudWebApi/SignalR/Services/NotificationPublisher.cs +++ b/AsbCloudWebApi/SignalR/Services/NotificationPublisher.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Threading.Tasks; using AsbCloudApp.Data; using AsbCloudApp.Repositories; +using AsbCloudWebApi.SignalR.Clients; using AsbCloudWebApi.SignalR.Messages; using Microsoft.AspNetCore.SignalR; @@ -12,11 +13,11 @@ namespace AsbCloudWebApi.SignalR.Services; public class NotificationPublisher { private readonly ConnectionManagerService connectionManagerService; - private readonly IHubContext notificationHubContext; + private readonly IHubContext notificationHubContext; private readonly INotificationRepository notificationRepository; public NotificationPublisher(ConnectionManagerService connectionManagerService, - IHubContext notificationHubContext, + IHubContext notificationHubContext, INotificationRepository notificationRepository) { this.connectionManagerService = connectionManagerService; @@ -70,8 +71,6 @@ public class NotificationPublisher CancellationToken cancellationToken) { await notificationHubContext.Clients.Client(connectionId) - .SendAsync("receiveNotifications", - message, - cancellationToken); + .ReceiveNotifications(message, cancellationToken); } } \ No newline at end of file diff --git a/AsbCloudWebApi/SignalR/TelemetryHub.cs b/AsbCloudWebApi/SignalR/TelemetryHub.cs index 9b7fd59d..69b6c628 100644 --- a/AsbCloudWebApi/SignalR/TelemetryHub.cs +++ b/AsbCloudWebApi/SignalR/TelemetryHub.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Authorization; +using AsbCloudWebApi.SignalR.Clients; +using Microsoft.AspNetCore.Authorization; namespace AsbCloudWebApi.SignalR { @@ -6,7 +7,7 @@ namespace AsbCloudWebApi.SignalR // https://docs.microsoft.com/ru-ru/aspnet/core/signalr/introduction?view=aspnetcore-5.0 [Authorize] - public class TelemetryHub : BaseHub + public class TelemetryHub : BaseHub { } diff --git a/AsbCloudWebApi/SignalR/WellInfoHub.cs b/AsbCloudWebApi/SignalR/WellInfoHub.cs index 677b4f64..553923fd 100644 --- a/AsbCloudWebApi/SignalR/WellInfoHub.cs +++ b/AsbCloudWebApi/SignalR/WellInfoHub.cs @@ -4,17 +4,18 @@ using AsbCloudApp.IntegrationEvents; using AsbCloudApp.IntegrationEvents.Interfaces; using AsbCloudApp.Services; using AsbCloudInfrastructure.Services; +using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.SignalR; namespace AsbCloudWebApi.SignalR; -public class WellInfoHub : BaseHub, IIntegrationEventHandler +public class WellInfoHub : BaseHub, IIntegrationEventHandler { - private readonly IHubContext hubContext; + private readonly IHubContext hubContext; private readonly IWellService wellService; private readonly WellInfoService wellInfoService; - public WellInfoHub(IHubContext hubContext, + public WellInfoHub(IHubContext hubContext, IWellService wellService, WellInfoService wellInfoService) { @@ -34,8 +35,6 @@ public class WellInfoHub : BaseHub, IIntegrationEventHandler w.Id == well.Id); await hubContext.Clients.Group($"well_info_{integrationEvent.IdWell}") - .SendAsync(method, new + .UpdateWellInfo(new { Well = well, WellInfo = wellInfo diff --git a/AsbCloudWebApi/Startup.cs b/AsbCloudWebApi/Startup.cs index f04a53d1..343df996 100644 --- a/AsbCloudWebApi/Startup.cs +++ b/AsbCloudWebApi/Startup.cs @@ -10,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.ResponseCompression; +using AsbCloudWebApi.Conventions; namespace AsbCloudWebApi { @@ -108,6 +109,10 @@ namespace AsbCloudWebApi options.EnableForHttps = true; options.Providers.Add(); }); + + services.AddMvc(c => + c.Conventions.Add(new ApiExplorerGroupPerVersionConvention()) + ); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) @@ -116,6 +121,7 @@ namespace AsbCloudWebApi app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1"); + c.SwaggerEndpoint("/swagger/signalr/swagger.json", "signalr"); c.EnablePersistAuthorization(); c.EnableFilter(); c.DisplayOperationId(); From 11163bf977d420bb1c669e592ab4d84196597e5e Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Mon, 30 Oct 2023 12:33:42 +0500 Subject: [PATCH 02/12] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B2=20ReportsHub,=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BD=D0=B5=D0=BD=D1=83=D0=B6=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ReportController.cs | 18 ++++----------- AsbCloudWebApi/SignalR/BaseHub.cs | 5 ----- AsbCloudWebApi/SignalR/ReportsHub.cs | 22 ++++--------------- 3 files changed, 8 insertions(+), 37 deletions(-) diff --git a/AsbCloudWebApi/Controllers/ReportController.cs b/AsbCloudWebApi/Controllers/ReportController.cs index 5e7a8fc2..c9f0c8d9 100644 --- a/AsbCloudWebApi/Controllers/ReportController.cs +++ b/AsbCloudWebApi/Controllers/ReportController.cs @@ -22,10 +22,10 @@ namespace AsbCloudWebApi.Controllers private readonly IReportService reportService; private readonly FileService fileService; private readonly IWellService wellService; - private readonly IHubContext reportsHubContext; + private readonly IHubContext reportsHubContext; public ReportController(IReportService reportService, IWellService wellService, - FileService fileService, IHubContext reportsHubContext) + FileService fileService, IHubContext reportsHubContext) { this.reportService = reportService; this.fileService = fileService; @@ -60,18 +60,8 @@ namespace AsbCloudWebApi.Controllers void HandleReportProgressAsync(object progress, string id) => Task.Run(async() => { - //reportsHubContext.Clients.Group($"Report_{id}") - // .GetReportProgressTest(progress, token); - //.ConfigureAwait(false); - - //await reportsHubContext.Clients.Group($"Report_{id}") - // .GetReportProgress(progress, token); - - await reportsHubContext.Clients.Group($"Report_{id}").SendAsync( - nameof(IReportHubClient.GetReportProgress), - progress, - token - ).ConfigureAwait(false); + await reportsHubContext.Clients.Group($"Report_{id}") + .GetReportProgress(progress, token); }, token); var id = reportService.EnqueueCreateReportWork(idWell, (int)idUser, diff --git a/AsbCloudWebApi/SignalR/BaseHub.cs b/AsbCloudWebApi/SignalR/BaseHub.cs index 1bb151c1..28de8ab5 100644 --- a/AsbCloudWebApi/SignalR/BaseHub.cs +++ b/AsbCloudWebApi/SignalR/BaseHub.cs @@ -12,8 +12,3 @@ public abstract class BaseHub : Hub where T : class public virtual Task RemoveFromGroup(string groupName) => Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName); } - -public abstract class BaseHub2 : Hub -{ - -} \ No newline at end of file diff --git a/AsbCloudWebApi/SignalR/ReportsHub.cs b/AsbCloudWebApi/SignalR/ReportsHub.cs index c4335396..f0608eac 100644 --- a/AsbCloudWebApi/SignalR/ReportsHub.cs +++ b/AsbCloudWebApi/SignalR/ReportsHub.cs @@ -2,7 +2,6 @@ using AsbCloudInfrastructure.Background; using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.SignalR; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -16,8 +15,7 @@ namespace AsbCloudWebApi.SignalR /// ReportsHub /// [Authorize] - public class ReportsHub : BaseHub2 - //BaseHub //Hub //BaseHub<> + public class ReportsHub : BaseHub { private readonly BackgroundWorker backgroundWorker; @@ -31,10 +29,9 @@ namespace AsbCloudWebApi.SignalR /// /// /// - public async Task AddToGroup(string groupName) + public override async Task AddToGroup(string groupName) { - //await this.AddToGroup(groupName); - //await this.Groups.AddToGroupAsync(Context.ConnectionId, groupName); + await base.AddToGroup(groupName); var workId = groupName.Replace("Report_", ""); var work = backgroundWorker.WorkStore.RunOnceQueue.FirstOrDefault(work => work.Id == workId); @@ -51,19 +48,8 @@ namespace AsbCloudWebApi.SignalR progress.Operation = state.State; progress.Progress = (float)state.Progress; } - await Clients.Group(groupName).SendAsync( - nameof(IReportHubClient.GetReportProgress), - progress, - CancellationToken.None - ); - - //await Clients.Group(groupName).GetReportProgress(progress, CancellationToken.None); + await Clients.Group(groupName).GetReportProgress(progress, CancellationToken.None); } - - //public async Task GetReportProgressTest(object obj, CancellationToken token) - //{ - // await Clients.All.GetReportProgressTest(obj, token); - //} } } From d8f4094d52bb5bfbb31890b80c6ab87f0d2642c8 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 7 Nov 2023 14:02:04 +0500 Subject: [PATCH 03/12] =?UTF-8?q?1.=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=B8=D1=80=D0=B5=D0=BA=D1=82=D0=B8=D0=B2=D0=B0?= =?UTF-8?q?=20UseSpa=20=D0=B8=D0=B7=20ConfigureServices=202.=20=D0=A1?= =?UTF-8?q?=D1=87=D0=B8=D1=82=D1=8B=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20ip=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B8=D0=B7=20=D0=B7=D0=B0=D0=B3=D0=BE=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B0=20"X-Real-IP"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/Middlewares/RequerstTrackerMiddleware.cs | 5 +++-- AsbCloudWebApi/Startup.cs | 5 ----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/AsbCloudWebApi/Middlewares/RequerstTrackerMiddleware.cs b/AsbCloudWebApi/Middlewares/RequerstTrackerMiddleware.cs index e8910b5d..392b3bca 100644 --- a/AsbCloudWebApi/Middlewares/RequerstTrackerMiddleware.cs +++ b/AsbCloudWebApi/Middlewares/RequerstTrackerMiddleware.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Org.BouncyCastle.Asn1.Ocsp; +using System.Linq; using System.Threading.Tasks; namespace AsbCloudWebApi.Middlewares @@ -18,10 +18,11 @@ namespace AsbCloudWebApi.Middlewares public async Task InvokeAsync(HttpContext context) { var service = context.RequestServices.GetRequiredService(); + var clientIp = context.Request.Headers["X-Real-IP"].FirstOrDefault(); var requestLog = new AsbCloudApp.Data.RequestLogDto { UserLogin = context.User.Identity?.Name ?? string.Empty, - UserIp = context.Connection?.RemoteIpAddress?.ToString(), + UserIp = clientIp ?? context.Connection?.RemoteIpAddress?.ToString(), RequestMethod = context.Request.Method, RequestPath = context.Request.Path.Value, RequestContentLength = context.Request.ContentLength, diff --git a/AsbCloudWebApi/Startup.cs b/AsbCloudWebApi/Startup.cs index f04a53d1..dd49dfad 100644 --- a/AsbCloudWebApi/Startup.cs +++ b/AsbCloudWebApi/Startup.cs @@ -158,11 +158,6 @@ namespace AsbCloudWebApi endpoints.MapHub("/hubs/telemetry"); endpoints.MapHub("/hubs/reports"); }); - - app.UseSpa(spa => - { - spa.Options.SourcePath = "wwwroot"; - }); } } } From 0ca686434907ab45b5b9a20e956c46eb873f7912 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 7 Nov 2023 15:16:59 +0500 Subject: [PATCH 04/12] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=BC=D0=B5=D1=80=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20nginx.conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/Docs/Nginx/nginx.conf | 151 +++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 AsbCloudWebApi/Docs/Nginx/nginx.conf diff --git a/AsbCloudWebApi/Docs/Nginx/nginx.conf b/AsbCloudWebApi/Docs/Nginx/nginx.conf new file mode 100644 index 00000000..362ba811 --- /dev/null +++ b/AsbCloudWebApi/Docs/Nginx/nginx.conf @@ -0,0 +1,151 @@ +user www-data; +worker_processes auto; +pid /run/nginx.pid; +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 768; + # multi_accept on; +} + +http { + +proxy_cache_path /home/asb/web-content/cache keys_zone=map-cache:1024m; + +server{ + listen 5085; + charset UTF-8; + + location / { + root /home/asb/public_files; + autoindex on; + autoindex_exact_size off; + autoindex_format html; + autoindex_localtime on; + } +} + +server { + listen 5090; + proxy_buffering on; + proxy_buffer_size 1M; + proxy_buffers 48 1M; + proxy_cache_lock on; + proxy_cache_lock_age 5s; + proxy_http_version 1.1; + proxy_cache_valid 200 61d; + proxy_cache_use_stale error timeout; + + + # ui- + root /home/asb/AsbCloudUI; + index index.html; + + location / { + try_files $uri /index.html; + } + + #, /api /auth /hubs + location ~ ^/(api|auth|hubs)/ { + + #, + proxy_pass http://127.0.0.1:5000; + + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /favicon.ico { + alias /home/asb/web-content/images/favicon.ico; + add_header Cache-Control "public"; + expires 4h; + } + + location /config.json { + alias /home/asb/web-content/config.json; + add_header Cache-Control "public"; + expires 4h; + } + + location /images/ { + root /home/asb/web-content; + add_header Cache-Control "public"; + expires 4h; + } + + location /map/a/ { + proxy_pass https://a.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } + location /map/b/ { + proxy_pass https://b.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } + location /map/c/ { + proxy_pass https://c.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } + location /map/ { + proxy_pass https://b.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } +} + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + ## + # SSL Settings + ## + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE + ssl_prefer_server_ciphers on; + + ## + # Logging Settings + ## + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # Virtual Host Configs + ## + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} From 9ba97ddcb5ce495505dde925b8104fa184c63101 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 7 Nov 2023 15:19:02 +0500 Subject: [PATCH 05/12] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/Docs/Nginx/{nginx.conf => nginx.conf.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename AsbCloudWebApi/Docs/Nginx/{nginx.conf => nginx.conf.md} (100%) diff --git a/AsbCloudWebApi/Docs/Nginx/nginx.conf b/AsbCloudWebApi/Docs/Nginx/nginx.conf.md similarity index 100% rename from AsbCloudWebApi/Docs/Nginx/nginx.conf rename to AsbCloudWebApi/Docs/Nginx/nginx.conf.md From 4927f290569d050725489ab6492a0e409093c2fc Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 7 Nov 2023 15:20:03 +0500 Subject: [PATCH 06/12] =?UTF-8?q?=D0=9A=D0=BE=D0=B4=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/Docs/Nginx/nginx.conf | 151 +++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 AsbCloudWebApi/Docs/Nginx/nginx.conf diff --git a/AsbCloudWebApi/Docs/Nginx/nginx.conf b/AsbCloudWebApi/Docs/Nginx/nginx.conf new file mode 100644 index 00000000..3d9675bd --- /dev/null +++ b/AsbCloudWebApi/Docs/Nginx/nginx.conf @@ -0,0 +1,151 @@ +user www-data; +worker_processes auto; +pid /run/nginx.pid; +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 768; + # multi_accept on; +} + +http { + +proxy_cache_path /home/asb/web-content/cache keys_zone=map-cache:1024m; + +server{ + listen 5085; + charset UTF-8; + + location / { + root /home/asb/public_files; + autoindex on; + autoindex_exact_size off; + autoindex_format html; + autoindex_localtime on; + } +} + +server { + listen 5090; + proxy_buffering on; + proxy_buffer_size 1M; + proxy_buffers 48 1M; + proxy_cache_lock on; + proxy_cache_lock_age 5s; + proxy_http_version 1.1; + proxy_cache_valid 200 61d; + proxy_cache_use_stale error timeout; + + + #путь до папки с ui-проектом в файловой системе + root /home/asb/AsbCloudUI; + index index.html; + + location / { + try_files $uri /index.html; + } + + #запрос, начинающийся с /api или /auth или /hubs + location ~ ^/(api|auth|hubs)/ { + + #адрес, на который будут пересылаться запросы от клиентов + proxy_pass http://127.0.0.1:5000; + + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /favicon.ico { + alias /home/asb/web-content/images/favicon.ico; + add_header Cache-Control "public"; + expires 4h; + } + + location /config.json { + alias /home/asb/web-content/config.json; + add_header Cache-Control "public"; + expires 4h; + } + + location /images/ { + root /home/asb/web-content; + add_header Cache-Control "public"; + expires 4h; + } + + location /map/a/ { + proxy_pass https://a.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } + location /map/b/ { + proxy_pass https://b.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } + location /map/c/ { + proxy_pass https://c.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } + location /map/ { + proxy_pass https://b.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } +} + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + ## + # SSL Settings + ## + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE + ssl_prefer_server_ciphers on; + + ## + # Logging Settings + ## + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # Virtual Host Configs + ## + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} From 5de2f28553dbfa79c3ea3d82de1ceb3443422faf Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 7 Nov 2023 15:24:56 +0500 Subject: [PATCH 07/12] =?UTF-8?q?=D0=A2=D0=B0=D0=B1=D1=83=D0=BB=D1=8F?= =?UTF-8?q?=D1=86=D0=B8=D1=8F,=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=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 --- AsbCloudWebApi/Docs/Nginx/nginx.conf | 148 +++++++++++------------ AsbCloudWebApi/Docs/Nginx/nginx.conf.md | 151 ------------------------ 2 files changed, 74 insertions(+), 225 deletions(-) delete mode 100644 AsbCloudWebApi/Docs/Nginx/nginx.conf.md diff --git a/AsbCloudWebApi/Docs/Nginx/nginx.conf b/AsbCloudWebApi/Docs/Nginx/nginx.conf index 3d9675bd..1700cae3 100644 --- a/AsbCloudWebApi/Docs/Nginx/nginx.conf +++ b/AsbCloudWebApi/Docs/Nginx/nginx.conf @@ -10,93 +10,93 @@ events { http { -proxy_cache_path /home/asb/web-content/cache keys_zone=map-cache:1024m; + proxy_cache_path /home/asb/web-content/cache keys_zone=map-cache:1024m; -server{ - listen 5085; - charset UTF-8; + server{ + listen 5085; + charset UTF-8; - location / { - root /home/asb/public_files; - autoindex on; - autoindex_exact_size off; - autoindex_format html; - autoindex_localtime on; - } -} + location / { + root /home/asb/public_files; + autoindex on; + autoindex_exact_size off; + autoindex_format html; + autoindex_localtime on; + } + } -server { - listen 5090; - proxy_buffering on; - proxy_buffer_size 1M; - proxy_buffers 48 1M; - proxy_cache_lock on; - proxy_cache_lock_age 5s; - proxy_http_version 1.1; - proxy_cache_valid 200 61d; - proxy_cache_use_stale error timeout; + server { + listen 5090; + proxy_buffering on; + proxy_buffer_size 1M; + proxy_buffers 48 1M; + proxy_cache_lock on; + proxy_cache_lock_age 5s; + proxy_http_version 1.1; + proxy_cache_valid 200 61d; + proxy_cache_use_stale error timeout; - #путь до папки с ui-проектом в файловой системе - root /home/asb/AsbCloudUI; - index index.html; + #путь до папки с ui-проектом в файловой системе + root /home/asb/AsbCloudUI; + index index.html; - location / { - try_files $uri /index.html; - } + location / { + try_files $uri /index.html; + } - #запрос, начинающийся с /api или /auth или /hubs - location ~ ^/(api|auth|hubs)/ { + #запрос, начинающийся с /api или /auth или /hubs + location ~ ^/(api|auth|hubs)/ { - #адрес, на который будут пересылаться запросы от клиентов - proxy_pass http://127.0.0.1:5000; + #адрес, на который будут пересылаться запросы от клиентов + proxy_pass http://127.0.0.1:5000; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } - location /favicon.ico { - alias /home/asb/web-content/images/favicon.ico; - add_header Cache-Control "public"; - expires 4h; - } + location /favicon.ico { + alias /home/asb/web-content/images/favicon.ico; + add_header Cache-Control "public"; + expires 4h; + } - location /config.json { - alias /home/asb/web-content/config.json; - add_header Cache-Control "public"; - expires 4h; - } + location /config.json { + alias /home/asb/web-content/config.json; + add_header Cache-Control "public"; + expires 4h; + } - location /images/ { - root /home/asb/web-content; - add_header Cache-Control "public"; - expires 4h; - } + location /images/ { + root /home/asb/web-content; + add_header Cache-Control "public"; + expires 4h; + } - location /map/a/ { - proxy_pass https://a.tile.openstreetmap.org/; - proxy_cache map-cache; - proxy_cache_key $request_uri; - } - location /map/b/ { - proxy_pass https://b.tile.openstreetmap.org/; - proxy_cache map-cache; - proxy_cache_key $request_uri; - } - location /map/c/ { - proxy_pass https://c.tile.openstreetmap.org/; - proxy_cache map-cache; - proxy_cache_key $request_uri; - } - location /map/ { - proxy_pass https://b.tile.openstreetmap.org/; - proxy_cache map-cache; - proxy_cache_key $request_uri; - } -} + location /map/a/ { + proxy_pass https://a.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } + location /map/b/ { + proxy_pass https://b.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } + location /map/c/ { + proxy_pass https://c.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } + location /map/ { + proxy_pass https://b.tile.openstreetmap.org/; + proxy_cache map-cache; + proxy_cache_key $request_uri; + } + } ## # Basic Settings diff --git a/AsbCloudWebApi/Docs/Nginx/nginx.conf.md b/AsbCloudWebApi/Docs/Nginx/nginx.conf.md deleted file mode 100644 index 362ba811..00000000 --- a/AsbCloudWebApi/Docs/Nginx/nginx.conf.md +++ /dev/null @@ -1,151 +0,0 @@ -user www-data; -worker_processes auto; -pid /run/nginx.pid; -include /etc/nginx/modules-enabled/*.conf; - -events { - worker_connections 768; - # multi_accept on; -} - -http { - -proxy_cache_path /home/asb/web-content/cache keys_zone=map-cache:1024m; - -server{ - listen 5085; - charset UTF-8; - - location / { - root /home/asb/public_files; - autoindex on; - autoindex_exact_size off; - autoindex_format html; - autoindex_localtime on; - } -} - -server { - listen 5090; - proxy_buffering on; - proxy_buffer_size 1M; - proxy_buffers 48 1M; - proxy_cache_lock on; - proxy_cache_lock_age 5s; - proxy_http_version 1.1; - proxy_cache_valid 200 61d; - proxy_cache_use_stale error timeout; - - - # ui- - root /home/asb/AsbCloudUI; - index index.html; - - location / { - try_files $uri /index.html; - } - - #, /api /auth /hubs - location ~ ^/(api|auth|hubs)/ { - - #, - proxy_pass http://127.0.0.1:5000; - - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - - location /favicon.ico { - alias /home/asb/web-content/images/favicon.ico; - add_header Cache-Control "public"; - expires 4h; - } - - location /config.json { - alias /home/asb/web-content/config.json; - add_header Cache-Control "public"; - expires 4h; - } - - location /images/ { - root /home/asb/web-content; - add_header Cache-Control "public"; - expires 4h; - } - - location /map/a/ { - proxy_pass https://a.tile.openstreetmap.org/; - proxy_cache map-cache; - proxy_cache_key $request_uri; - } - location /map/b/ { - proxy_pass https://b.tile.openstreetmap.org/; - proxy_cache map-cache; - proxy_cache_key $request_uri; - } - location /map/c/ { - proxy_pass https://c.tile.openstreetmap.org/; - proxy_cache map-cache; - proxy_cache_key $request_uri; - } - location /map/ { - proxy_pass https://b.tile.openstreetmap.org/; - proxy_cache map-cache; - proxy_cache_key $request_uri; - } -} - - ## - # Basic Settings - ## - - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; - # server_tokens off; - - # server_names_hash_bucket_size 64; - # server_name_in_redirect off; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - ## - # SSL Settings - ## - - ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE - ssl_prefer_server_ciphers on; - - ## - # Logging Settings - ## - - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - - ## - # Gzip Settings - ## - - gzip on; - - # gzip_vary on; - # gzip_proxied any; - # gzip_comp_level 6; - # gzip_buffers 16 8k; - # gzip_http_version 1.1; - # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; - - ## - # Virtual Host Configs - ## - - include /etc/nginx/conf.d/*.conf; - include /etc/nginx/sites-enabled/*; -} From 107a81f24db7cf19a55ff56ebe502a50c12a5e71 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Thu, 9 Nov 2023 15:18:07 +0500 Subject: [PATCH 08/12] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D0=B0=D0=BC=20=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SAUB/TelemetryDataBaseController.cs | 16 +++---- .../SAUB/TelemetryDataSaubController.cs | 14 ++++--- .../SAUB/TelemetryDataSpinController.cs | 9 +++- .../SignalR/Clients/INotificationHubClient.cs | 5 ++- .../SignalR/Clients/IReportHubClient.cs | 3 +- .../SignalR/Clients/ITelemetryHubClient.cs | 42 ++++++++++++++++--- .../SignalR/Clients/IWellInfoHubClient.cs | 3 +- 7 files changed, 68 insertions(+), 24 deletions(-) diff --git a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs index 4649d91d..c19cfbd2 100644 --- a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs +++ b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs @@ -2,6 +2,7 @@ using AsbCloudApp.Requests; using AsbCloudApp.Services; using AsbCloudWebApi.SignalR; +using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; @@ -23,20 +24,22 @@ namespace AsbCloudWebApi.Controllers.SAUB protected readonly IWellService wellService; private readonly ITelemetryService telemetryService; private readonly ITelemetryDataService telemetryDataService; - private readonly IHubContext telemetryHubContext; - - public string SignalRMethodGetDataName { get; protected set; } = "ReceiveData"; + protected readonly IHubContext telemetryHubContext; + public Action> SignalrReceiveDataOperation { get; set; } public TelemetryDataBaseController( ITelemetryService telemetryService, ITelemetryDataService telemetryDataService, IWellService wellService, - IHubContext telemetryHubContext) + IHubContext telemetryHubContext) { this.telemetryService = telemetryService; this.telemetryDataService = telemetryDataService; this.wellService = wellService; this.telemetryHubContext = telemetryHubContext; + this.SignalrReceiveDataOperation = (int? idWell, IEnumerable dtos) => { + telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveData(dtos, CancellationToken.None); + }; } /// @@ -55,8 +58,7 @@ namespace AsbCloudWebApi.Controllers.SAUB var idWell = telemetryService.GetIdWellByTelemetryUid(uid); if (idWell is not null && dtos.Any()) - _ = Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}") - .SendAsync(SignalRMethodGetDataName, dtos), CancellationToken.None); + _ = Task.Run(() => SignalrReceiveDataOperation.Invoke(idWell, dtos)); return Ok(); } @@ -75,7 +77,7 @@ namespace AsbCloudWebApi.Controllers.SAUB [Permission] public virtual async Task>> GetDataAsync(int idWell, DateTime begin = default, - int intervalSec = 600, + int intervalSec = 600, int approxPointsCount = 1024, //TODO: сделать cancellationToken обязательным CancellationToken token = default) diff --git a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSaubController.cs b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSaubController.cs index be694818..6cee68c0 100644 --- a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSaubController.cs +++ b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSaubController.cs @@ -1,12 +1,14 @@ using AsbCloudApp.Data.SAUB; using AsbCloudApp.Services; using AsbCloudWebApi.SignalR; +using AsbCloudWebApi.SignalR.Clients; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; -using System.Threading.Tasks; -using System.Threading; using System; -using Microsoft.AspNetCore.Http; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; namespace AsbCloudWebApi.Controllers.SAUB { @@ -23,14 +25,16 @@ namespace AsbCloudWebApi.Controllers.SAUB ITelemetryService telemetryService, ITelemetryDataSaubService telemetryDataService, IWellService wellService, - IHubContext telemetryHubContext) + IHubContext telemetryHubContext) : base( telemetryService, telemetryDataService, wellService, telemetryHubContext) { - SignalRMethodGetDataName = "ReceiveDataSaub"; + SignalrReceiveDataOperation = (int? idWell, IEnumerable dtos) => { + telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveDataSaub(dtos, CancellationToken.None); + }; telemetryDataSaubService = telemetryDataService; } diff --git a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSpinController.cs b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSpinController.cs index c8b55cc6..05ae423f 100644 --- a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSpinController.cs +++ b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSpinController.cs @@ -1,8 +1,11 @@ using AsbCloudApp.Data.SAUB; using AsbCloudApp.Services; using AsbCloudWebApi.SignalR; +using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; +using System.Collections.Generic; +using System.Threading; namespace AsbCloudWebApi.Controllers.SAUB { @@ -17,14 +20,16 @@ namespace AsbCloudWebApi.Controllers.SAUB ITelemetryService telemetryService, ITelemetryDataService telemetryDataService, IWellService wellService, - IHubContext telemetryHubContext) + IHubContext telemetryHubContext) : base( telemetryService, telemetryDataService, wellService, telemetryHubContext) { - SignalRMethodGetDataName = "ReceiveDataSpin"; + SignalrReceiveDataOperation = (int? idWell, IEnumerable dtos) => { + telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveDataSpin(dtos, CancellationToken.None); + }; } } } diff --git a/AsbCloudWebApi/SignalR/Clients/INotificationHubClient.cs b/AsbCloudWebApi/SignalR/Clients/INotificationHubClient.cs index aae2cb77..09c36851 100644 --- a/AsbCloudWebApi/SignalR/Clients/INotificationHubClient.cs +++ b/AsbCloudWebApi/SignalR/Clients/INotificationHubClient.cs @@ -12,11 +12,12 @@ namespace AsbCloudWebApi.SignalR.Clients public interface INotificationHubClient { /// - /// Отправка клиенту сообщения с уведомлением + /// Отправка клиенту сообщения с уведомлением. + /// Для подписки на метод необходимо отправить connectionId /// /// сообщение с уведомлением /// /// - Task ReceiveNotifications(NotificationMessage message, CancellationToken token = default); + Task ReceiveNotifications(NotificationMessage message, CancellationToken token); } } diff --git a/AsbCloudWebApi/SignalR/Clients/IReportHubClient.cs b/AsbCloudWebApi/SignalR/Clients/IReportHubClient.cs index 6c25d829..dde7da3f 100644 --- a/AsbCloudWebApi/SignalR/Clients/IReportHubClient.cs +++ b/AsbCloudWebApi/SignalR/Clients/IReportHubClient.cs @@ -11,7 +11,8 @@ namespace AsbCloudWebApi.SignalR.Clients public interface IReportHubClient { /// - /// Отправка клиенту сообщения о статусе формирования отчета + /// Отправка клиенту сообщения о статусе формирования отчета. + /// Для подписки на метод необходимо отправить сообщение в формате $"Report_{id}" /// /// статус формирования отчета /// diff --git a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs index fa915aa0..6e1578be 100644 --- a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs +++ b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs @@ -1,8 +1,6 @@ -using AsbCloudApp.Data; -using AsbCloudApp.Data.SAUB; +using AsbCloudApp.Data.SAUB; using SignalRSwaggerGen.Attributes; using System.Collections; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -15,12 +13,13 @@ namespace AsbCloudWebApi.SignalR.Clients public interface ITelemetryHubClient { /// - /// Отправка клиенту уведомления о доставке с панели drill test данных + /// Отправка клиенту уведомления о доставке с панели drill test данных. + /// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}" /// /// /// /// - Task ReceiveDrilltestData(DrillTestDto dto, CancellationToken token = default); + Task ReceiveDrilltestData(DrillTestDto dto, CancellationToken token); /// /// @@ -29,6 +28,37 @@ namespace AsbCloudWebApi.SignalR.Clients /// /// /// - Task UpdateProcessMap(IEnumerable dtos, CancellationToken token = default); + Task UpdateProcessMap(IEnumerable dtos, CancellationToken token); + + /// + /// Отправка данных клиенту. + /// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}" + /// + /// + /// + /// + /// + Task ReceiveData(IEnumerable dtos, CancellationToken token); + + /// + /// Отправка сауб-данных клиенту. + /// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}" + /// + /// + /// + /// + /// + Task ReceiveDataSaub(IEnumerable dtos, CancellationToken token); + + /// + /// Отправка спин-данных клиенту. + /// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}" + /// + /// + /// + /// + /// + Task ReceiveDataSpin(IEnumerable dtos, CancellationToken token); + } } diff --git a/AsbCloudWebApi/SignalR/Clients/IWellInfoHubClient.cs b/AsbCloudWebApi/SignalR/Clients/IWellInfoHubClient.cs index a898d207..110143ed 100644 --- a/AsbCloudWebApi/SignalR/Clients/IWellInfoHubClient.cs +++ b/AsbCloudWebApi/SignalR/Clients/IWellInfoHubClient.cs @@ -13,10 +13,11 @@ namespace AsbCloudWebApi.SignalR.Clients { /// /// Отправка клиенту сообщения об обновлении информации о скважине + /// Для подписки на метод необходимо отправить сообщение в формате $"well_info_{idWell}" /// /// информация о скважине /// /// - Task UpdateWellInfo(object wellInfo, CancellationToken token = default); + Task UpdateWellInfo(object wellInfo, CancellationToken token); } } From 030222311abe06ddd341cfeae0d7e7aafca78794 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Thu, 9 Nov 2023 15:55:49 +0500 Subject: [PATCH 09/12] nit --- .../SAUB/TelemetryDataBaseController.cs | 9 ++++----- .../SAUB/TelemetryDataSaubController.cs | 8 +++++--- .../SAUB/TelemetryDataSpinController.cs | 8 +++++--- AsbCloudWebApi/DependencyInjection.cs | 11 ++++++----- .../SignalR/Clients/ITelemetryHubClient.cs | 18 +++++------------- 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs index 9c04bd58..57a97043 100644 --- a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs +++ b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs @@ -25,7 +25,6 @@ namespace AsbCloudWebApi.Controllers.SAUB private readonly ITelemetryService telemetryService; private readonly ITelemetryDataService telemetryDataService; protected readonly IHubContext telemetryHubContext; - public Action> SignalrReceiveDataOperation { get; set; } public TelemetryDataBaseController( ITelemetryService telemetryService, @@ -37,11 +36,11 @@ namespace AsbCloudWebApi.Controllers.SAUB this.telemetryDataService = telemetryDataService; this.wellService = wellService; this.telemetryHubContext = telemetryHubContext; - this.SignalrReceiveDataOperation = (int? idWell, IEnumerable dtos) => { - telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveData(dtos, CancellationToken.None); - }; + } + protected abstract Task SignalRNotifyAsync(int idWell, IEnumerable dtos, CancellationToken token); + /// /// Принимает данные от разных систем по скважине /// @@ -58,7 +57,7 @@ namespace AsbCloudWebApi.Controllers.SAUB var idWell = telemetryService.GetIdWellByTelemetryUid(uid); if (idWell is not null && dtos.Any()) - _ = Task.Run(() => SignalrReceiveDataOperation.Invoke(idWell, dtos)); + _ = Task.Run(() => SignalRNotifyAsync(idWell.Value, dtos, CancellationToken.None)); return Ok(); } diff --git a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSaubController.cs b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSaubController.cs index 6cee68c0..e3791655 100644 --- a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSaubController.cs +++ b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSaubController.cs @@ -32,9 +32,6 @@ namespace AsbCloudWebApi.Controllers.SAUB wellService, telemetryHubContext) { - SignalrReceiveDataOperation = (int? idWell, IEnumerable dtos) => { - telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveDataSaub(dtos, CancellationToken.None); - }; telemetryDataSaubService = telemetryDataService; } @@ -66,5 +63,10 @@ namespace AsbCloudWebApi.Controllers.SAUB var fileName = $"DataSaub idWell{idWell} {beginDate:yyyy-MM-DDTHH-mm} - {endDate:yyyy-MM-DDTHH-mm}.zip"; return File(stream, "application/octet-stream", fileName); } + + protected override Task SignalRNotifyAsync(int idWell, IEnumerable dtos, CancellationToken token) + { + return telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveDataSaub(dtos, token); + } } } diff --git a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSpinController.cs b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSpinController.cs index 05ae423f..9c81af02 100644 --- a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSpinController.cs +++ b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataSpinController.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using System.Collections.Generic; using System.Threading; +using System.Threading.Tasks; namespace AsbCloudWebApi.Controllers.SAUB { @@ -26,10 +27,11 @@ namespace AsbCloudWebApi.Controllers.SAUB telemetryDataService, wellService, telemetryHubContext) + {} + + protected override Task SignalRNotifyAsync(int idWell, IEnumerable dtos, CancellationToken token) { - SignalrReceiveDataOperation = (int? idWell, IEnumerable dtos) => { - telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveDataSpin(dtos, CancellationToken.None); - }; + return telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveDataSpin(dtos, token); } } } diff --git a/AsbCloudWebApi/DependencyInjection.cs b/AsbCloudWebApi/DependencyInjection.cs index be2baf9b..788c661d 100644 --- a/AsbCloudWebApi/DependencyInjection.cs +++ b/AsbCloudWebApi/DependencyInjection.cs @@ -19,6 +19,7 @@ using AsbCloudWebApi.SignalR; using AsbCloudWebApi.SignalR.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.OpenApi.Any; +using Swashbuckle.AspNetCore.SwaggerGen; namespace AsbCloudWebApi { @@ -80,11 +81,11 @@ namespace AsbCloudWebApi c.IncludeXmlComments(xmlPath, includeControllerXmlComment); c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "AsbCloudApp.xml"), includeControllerXmlComment); - c.AddSignalRSwaggerGen((_) => { - _.DisplayInDocument("signalr"); - _.UseHubXmlCommentsSummaryAsTagDescription = true; - _.UseHubXmlCommentsSummaryAsTag = true; - _.UseXmlComments(xmlPath); + c.AddSignalRSwaggerGen(options => { + options.DisplayInDocument("signalr"); + options.UseHubXmlCommentsSummaryAsTagDescription = true; + options.UseHubXmlCommentsSummaryAsTag = true; + options.UseXmlComments(xmlPath); }); }); } diff --git a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs index 6e1578be..d0933bbb 100644 --- a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs +++ b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs @@ -1,6 +1,8 @@ using AsbCloudApp.Data.SAUB; +using Microsoft.AspNetCore.Mvc; using SignalRSwaggerGen.Attributes; using System.Collections; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -28,17 +30,7 @@ namespace AsbCloudWebApi.SignalR.Clients /// /// /// - Task UpdateProcessMap(IEnumerable dtos, CancellationToken token); - - /// - /// Отправка данных клиенту. - /// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}" - /// - /// - /// - /// - /// - Task ReceiveData(IEnumerable dtos, CancellationToken token); + Task UpdateProcessMap(IEnumerable dtos, CancellationToken token); /// /// Отправка сауб-данных клиенту. @@ -48,7 +40,7 @@ namespace AsbCloudWebApi.SignalR.Clients /// /// /// - Task ReceiveDataSaub(IEnumerable dtos, CancellationToken token); + Task ReceiveDataSaub(IEnumerable dtos, CancellationToken token); /// /// Отправка спин-данных клиенту. @@ -58,7 +50,7 @@ namespace AsbCloudWebApi.SignalR.Clients /// /// /// - Task ReceiveDataSpin(IEnumerable dtos, CancellationToken token); + Task ReceiveDataSpin(IEnumerable dtos, CancellationToken token); } } From 9f932e5ea8016d2f73d998b96478e648fd36ce6a Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Fri, 10 Nov 2023 09:56:46 +0500 Subject: [PATCH 10/12] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=82=D0=B8=D0=BF=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D1=83?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0=20UpdateProcessMap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ProcessMaps/ProcessMapBaseController.cs | 2 +- AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs index e512aca2..6dc1d7d6 100644 --- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs @@ -205,7 +205,7 @@ public abstract class ProcessMapBaseController : ControllerBase await telemetryHubContext.Clients .Group($"{SignalRMethod}_{idWell}") - .UpdateProcessMap(dtos, cancellationToken); + .UpdateProcessMap(dtos, cancellationToken); } private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken) diff --git a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs index d0933bbb..971659a2 100644 --- a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs +++ b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs @@ -1,5 +1,4 @@ using AsbCloudApp.Data.SAUB; -using Microsoft.AspNetCore.Mvc; using SignalRSwaggerGen.Attributes; using System.Collections; using System.Collections.Generic; @@ -26,11 +25,10 @@ namespace AsbCloudWebApi.SignalR.Clients /// /// /// - /// /// /// /// - Task UpdateProcessMap(IEnumerable dtos, CancellationToken token); + Task UpdateProcessMap(IEnumerable dtos, CancellationToken token); /// /// Отправка сауб-данных клиенту. From 3fc2184f4c6d123c877920a99997603cca7b3ed3 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Fri, 10 Nov 2023 10:05:01 +0500 Subject: [PATCH 11/12] =?UTF-8?q?location=20=D0=B4=D0=BB=D1=8F=20swagger?= =?UTF-8?q?=20=D0=B2=20nginx.conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/Docs/Nginx/nginx.conf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/AsbCloudWebApi/Docs/Nginx/nginx.conf b/AsbCloudWebApi/Docs/Nginx/nginx.conf index 1700cae3..f33640db 100644 --- a/AsbCloudWebApi/Docs/Nginx/nginx.conf +++ b/AsbCloudWebApi/Docs/Nginx/nginx.conf @@ -58,6 +58,16 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } + location /swagger/ { + proxy_pass http://127.0.0.1:5000/swagger/; + + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + location /favicon.ico { alias /home/asb/web-content/images/favicon.ico; add_header Cache-Control "public"; From 40033226307be66dfd3f762609bd988bc97abf97 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Fri, 10 Nov 2023 16:23:05 +0500 Subject: [PATCH 12/12] doc --- AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs index 971659a2..3e82572b 100644 --- a/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs +++ b/AsbCloudWebApi/SignalR/Clients/ITelemetryHubClient.cs @@ -34,7 +34,6 @@ namespace AsbCloudWebApi.SignalR.Clients /// Отправка сауб-данных клиенту. /// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}" /// - /// /// /// /// @@ -44,7 +43,6 @@ namespace AsbCloudWebApi.SignalR.Clients /// Отправка спин-данных клиенту. /// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}" /// - /// /// /// ///