Ejemplo n.º 1
0
        public ActionResult Run
        (
            [FromServices] IReportingServicesClient reportingServicesClient,
            string customerShortName,
            string projectShortName,
            Guid jobId,
            Guid flowchartRunId,
            Operations operation,
            bool reRunRateGeneration = false
        )
        {
            var job          = _jobProxy.GetJob(customerShortName, projectShortName, jobId);
            var flowchartRun = job.flowchartRunRequest.FirstOrDefault(x => x.flowchartRunUUID == flowchartRunId);

            if (flowchartRun == null)
            {
                throw new NullReferenceException("The flowchart run was not present in the job.");
            }
            if (!reRunRateGeneration)
            {
                _workStatusProxy.Add(new WorkStatus(flowchartRunId, false, GetPercentage(operation), AnalyticsRunStatus.Running));
            }

            if (!reRunRateGeneration && operation == Operations.GenerateMemberMonthInfo)
            {
                var index = job.flowchartRunRequest.IndexOf(flowchartRun);

                if (index > 0)
                {
                    var percentage = Calculations.Percentage(_config.PreCacheDBPercentageContribution, index, job.flowchartRunRequest.Count, 100);
                    _workStatusProxy.Add(new WorkStatus(jobId, false, percentage, AnalyticsRunStatus.Running));
                }
                else
                {
                    _workStatusProxy.Add(new WorkStatus(jobId, false, _config.PreCacheDBPercentageContribution, AnalyticsRunStatus.Running));

                    for (int i = 1; i < job.flowchartRunRequest.Count; i++)
                    {
                        _workStatusProxy.Add(new WorkStatus(job.flowchartRunRequest[i].flowchartRunUUID, false, GetPercentage(operation), AnalyticsRunStatus.Running));
                    }
                }
            }

            var model = new RatesCacheModel()
            {
                customerShortName           = customerShortName,
                flowchartRunId              = flowchartRunId,
                flowchartCatalogPopulations = flowchartRun.flowchartCatalogPopulations,
                operation          = operation,
                populationIds      = (job.populationIds == null || job.populationIds.Count == 0) ? null : job.populationIds, // passing an empty list causes it to not populate
                projectShortName   = projectShortName,
                hrSampleMeasureIDs = flowchartRun.hrSampleMeasureMetadata.Keys.ToList()
            };

            if (!SkipOperation(model, operation))
            {
                RunOperation(reportingServicesClient, model, reRunRateGeneration);
            }
            return(Ok());
        }
Ejemplo n.º 2
0
        private void RunOperation(IReportingServicesClient reportingServicesClient, RatesCacheModel model, bool reRunRateGeneration)
        {
            var json   = JsonConvert.SerializeObject(model);
            var method = GetServiceMethod(model.operation);

            var fallback  = _config.CacheDBPercentageContribution;
            var stopWatch = Stopwatch.StartNew();
            var response  = reportingServicesClient.Client.PostAsync(method, new StringContent(json, Encoding.UTF8, "application/json")).Result;

            _validation.ValidateResponse(response);

            if (!reRunRateGeneration)
            {
                _taskLogging.LogOperation
                (
                    model.customerShortName,
                    model.projectShortName,
                    model.operation.ToString(),
                    model.flowchartRunId,
                    stopWatch.Elapsed,
                    fallback
                );
            }

            var result    = response.Content.ReadAsStringAsync().Result;
            var succeeded = ((JProperty)JObject.Parse(result).First).Value.Value <bool>();

            if (!succeeded)
            {
                throw new OperationCanceledException($"Run failed for the following input: method: {method}, json: {json}");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Validations to decide if we can skip the task
        /// </summary>
        /// <param name="model"></param>
        /// <param name="operation"></param>
        /// <returns></returns>
        private bool SkipOperation(RatesCacheModel model, Operations operation)
        {
            bool skip = false;

            switch (operation)
            {
            case Operations.GenerateMemberMonthInfo:
                break;

            case Operations.GenerateHybridIdssReport:
                skip = model.hrSampleMeasureIDs.Count == 0;
                break;

            case Operations.GenerateHybridRates:
                skip = model.hrSampleMeasureIDs.Count == 0;
                break;

            case Operations.GenerateRates:
                break;

            case Operations.GenerateSupplementalSummaryByFileType:
                break;

            case Operations.GenerateSupplementalSummaryReport:
                break;

            case Operations.GenerateSupplementalSummaryReportByTable:
                break;

            case Operations.GenerateTableMeasureReport:
                break;

            default:
                break;
            }
            return(skip);
        }