| | | 1 | | using System; |
| | | 2 | | using System.Linq; |
| | | 3 | | using System.Threading.Tasks; |
| | | 4 | | using Microsoft.AspNetCore.Authorization; |
| | | 5 | | using Microsoft.AspNetCore.Mvc; |
| | | 6 | | using OzonOrdersWeb.Areas.Studio2.ViewModels.OzonWebhookViewModels; |
| | | 7 | | using Services.DataServices; |
| | | 8 | | using OzonDomains.Models.OzonWebhook; |
| | | 9 | | |
| | | 10 | | namespace OzonOrdersWeb.Areas.Studio2.Controllers |
| | | 11 | | { |
| | | 12 | | [Authorize(Roles = "User,Admin")] |
| | | 13 | | [Area("Studio2")] |
| | | 14 | | public class OzonWebhookLogController : Controller |
| | | 15 | | { |
| | | 16 | | private readonly OzonPushNotificationDataService _dataService; |
| | | 17 | | private readonly OzonClientServices _ozonClientServices; |
| | | 18 | | |
| | 0 | 19 | | public OzonWebhookLogController( |
| | 0 | 20 | | OzonPushNotificationDataService dataService, |
| | 0 | 21 | | OzonClientServices ozonClientServices) |
| | | 22 | | { |
| | 0 | 23 | | _dataService = dataService; |
| | 0 | 24 | | _ozonClientServices = ozonClientServices; |
| | 0 | 25 | | } |
| | | 26 | | |
| | | 27 | | [HttpGet] |
| | | 28 | | public IActionResult Index( |
| | | 29 | | string? messageType = null, |
| | | 30 | | int? clientId = null, |
| | | 31 | | string? processingStatus = null, |
| | | 32 | | string? postingNumber = null, |
| | | 33 | | DateTime? from = null, |
| | | 34 | | DateTime? to = null, |
| | | 35 | | int take = 200) => |
| | 0 | 36 | | RedirectToAction("Index", "JobLogs", new |
| | 0 | 37 | | { |
| | 0 | 38 | | area = "Studio2", |
| | 0 | 39 | | tab = "webhook", |
| | 0 | 40 | | messageType, |
| | 0 | 41 | | clientId, |
| | 0 | 42 | | processingStatus, |
| | 0 | 43 | | postingNumber, |
| | 0 | 44 | | from, |
| | 0 | 45 | | to, |
| | 0 | 46 | | take |
| | 0 | 47 | | }); |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Возвращает JSON с одной записью для отображения сырого payload в модальном окне. |
| | | 51 | | /// </summary> |
| | | 52 | | [HttpGet] |
| | | 53 | | public async Task<IActionResult> Details(long id) |
| | | 54 | | { |
| | 0 | 55 | | var record = await _dataService.GetByIdAsync(id); |
| | 0 | 56 | | if (record == null) |
| | 0 | 57 | | return NotFound(); |
| | | 58 | | |
| | 0 | 59 | | return Json(new |
| | 0 | 60 | | { |
| | 0 | 61 | | id = record.Id, |
| | 0 | 62 | | messageType = record.MessageType, |
| | 0 | 63 | | postingNumber = record.PostingNumber, |
| | 0 | 64 | | sellerId = record.SellerId, |
| | 0 | 65 | | warehouseId = record.WarehouseId, |
| | 0 | 66 | | processingStatus = record.ProcessingStatus, |
| | 0 | 67 | | errorMessage = record.ErrorMessage, |
| | 0 | 68 | | actionDetails = record.ActionDetails, |
| | 0 | 69 | | sourceIpAddress = record.SourceIpAddress, |
| | 0 | 70 | | receivedAt = record.ReceivedAt.ToString("dd.MM.yyyy HH:mm:ss"), |
| | 0 | 71 | | processedAt = record.ProcessedAt?.ToString("dd.MM.yyyy HH:mm:ss"), |
| | 0 | 72 | | rawPayload = record.RawPayload |
| | 0 | 73 | | }); |
| | 0 | 74 | | } |
| | | 75 | | } |
| | | 76 | | } |