public ActionResult PostRefreshPopulations([FromServices] IRouterClient routerClient, [FromServices] IStonebranchClient stonebranchClient, string customerShortName, string projectShortName, Guid id) { var job = _jobProxy.GetJob(customerShortName, projectShortName, id); var requestId = Guid.NewGuid(); _workStatusProxy.Add(job, AnalyticsRunStatus.Running, Calculations.Percentage(0, 3, 14, _config.PreTAPercentageContribution), true, true); var populationIds = (job.populationIds == null || job.populationIds.Count < 1) ? string.Empty : String.Join(',', job.populationIds); var projectConfig = _iam.GetProjectConfig(customerShortName, projectShortName); var stopWatch = Stopwatch.StartNew(); var json = $@" {{ 'requestUUID': '{requestId}', 'customerShortName': '{customerShortName}', 'projectShortName': '{projectShortName}', 'requestType': 'ReprocessPopulation', 'requestData': {{ 'populationIds': [{populationIds}], 'forceRefresh': false, }} }} "; var response = routerClient.Client.PostAsync("postRequest", new StringContent(json, Encoding.UTF8, "application/json")).Result; _validation.ValidateResponse(response); if (job.lastRouterRequests.Keys.Contains("RefreshPopulations")) { job.lastRouterRequests["RefreshPopulations"] = requestId.ToString(); } else { job.lastRouterRequests.Add("RefreshPopulations", requestId.ToString()); } _jobProxy.UpdateJob(job); _taskLogging.LogOperation(customerShortName, projectShortName, "Refresh Populations message posted.", job, stopWatch.Elapsed); return(Ok(requestId)); }
public IActionResult MREPlusEventDefinitions([FromServices] IDataExtractionClient dataExtractionClient, string customerShortName, string projectShortName, Guid id) { var job = _jobProxy.GetJob(customerShortName, projectShortName, id); var fileNameSuffix = DateTime.Now.ToString("yyyyMMddHHmmss"); var mrePlusEnabled = false; if (job.eventMrePlusOptions != null && Boolean.TryParse(job.eventMrePlusOptions.Value, out mrePlusEnabled) && mrePlusEnabled) { bool folderCreated = CreateFolder(dataExtractionClient, customerShortName, projectShortName, id); if (folderCreated) { job.eventMrePlusOptions.file_name_suffix = fileNameSuffix; bool isgZip = job.eventMrePlusOptions != null && job.eventMrePlusOptions.archive_format.ToLower() == "gzip"; var input = new { customerShortName = customerShortName, projectShortName = projectShortName, folderName = id.ToString() + @"/" + _config.MrePlusEventsFolderName, fileType = $"TAB|txt{(isgZip ? ".gz" : string.Empty)}", fileNameSuffix = fileNameSuffix }; var json = JsonConvert.SerializeObject(input); var method = "MassResultsExportPlusEventDefinitions_Rest"; var response = dataExtractionClient.Client.PostAsync(method, new StringContent(json, Encoding.UTF8, "application/json")).Result; _validation.ValidateResponse(response); var result = response.Content.ReadAsStringAsync().Result; var succeeded = ((JProperty)JObject.Parse(result).First).Value.Value <bool>(); if (!succeeded) { throw new OperationCanceledException($"MRE+ Event definition export failed for the following input: api: {method}, json: {json}"); } _jobProxy.UpdateJob(job); _logging.Log("MREPlusEventDefinitions completed", Orchestration.Shared.Domain.Log.LogLevels.Info); } else { _logging.Log("CreateMrePlusEventFolders_Rest failed", Orchestration.Shared.Domain.Log.LogLevels.Info); } } else { _logging.Log("Skipped running MREPlusEventDefinitions", Orchestration.Shared.Domain.Log.LogLevels.Info); } return(Ok()); }