public IActionResult GetCollections() { dynamic dataResults = null; try { dataResults = _preingestHandler.GetCollections(); } catch (Exception e) { _logger.LogError(e, "An exception was thrown : {0}, '{1}'.", e.Message, e.StackTrace); return(ValidationProblem(String.Format("An exception was thrown : {0}, '{1}'.", e.Message, e.StackTrace))); } finally { _logger.LogInformation("Exit UpdateProcessAction."); } if (dataResults == null) { return(NotFound("Not collections data found!")); } return(new JsonResult(dataResults)); }
public IActionResult SendNotification([FromBody] BodyEventMessageBody message) { if (message == null) { return(Problem("POST body JSON object is null!")); } var settings = new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() }, Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore }; object state = null; bool parse = Enum.TryParse(typeof(PreingestActionStates), message.State, out state); if (!parse) { return(Problem("Parsing state failed!")); } //trigger full events _eventHub.Clients.All.SendAsync(nameof(IEventHub.SendNoticeEventToClient), JsonConvert.SerializeObject(new EventHubMessage { EventDateTime = message.EventDateTime, SessionId = message.SessionId, Name = message.Name, State = (PreingestActionStates)state, Message = message.Message, Summary = message.HasSummary ? new PreingestStatisticsSummary { Accepted = message.Accepted, Processed = message.Processed, Rejected = message.Rejected, Start = message.Start.Value, End = message.End.Value } : null }, settings)).GetAwaiter().GetResult(); if ((PreingestActionStates)state == PreingestActionStates.Started || (PreingestActionStates)state == PreingestActionStates.Failed || (PreingestActionStates)state == PreingestActionStates.Completed) { //notify client update collections status string collectionsData = JsonConvert.SerializeObject(_preingestCollection.GetCollections(), settings); _eventHub.Clients.All.SendAsync(nameof(IEventHub.CollectionsStatus), collectionsData).GetAwaiter().GetResult(); //notify client collection /{ guid} status string collectionData = JsonConvert.SerializeObject(_preingestCollection.GetCollection(message.SessionId), settings); _eventHub.Clients.All.SendAsync(nameof(IEventHub.CollectionStatus), message.SessionId, collectionData).GetAwaiter().GetResult(); if ((PreingestActionStates)state == PreingestActionStates.Failed || (PreingestActionStates)state == PreingestActionStates.Completed) { _eventHub.Clients.All.SendAsync(nameof(IEventHub.SendNoticeToWorkerService), message.SessionId, collectionData).GetAwaiter().GetResult(); } } return(Ok()); }