Ejemplo n.º 1
0
        public async Task <IActionResult> Load([FromBody] LoadExtracts request)
        {
            if (!request.IsValid())
            {
                return(BadRequest());
            }

            string version = GetType().Assembly.GetName().Version.ToString();

            if (!request.LoadMpi)
            {
                var result = await _mediator.Send(request.LoadFromEmrCommand, HttpContext.RequestAborted);

                await _mediator.Publish(new ExtractLoaded("CareTreatment", version));

                return(Ok(result));
            }

            var dwhExtractsTask = Task.Run(() => _mediator.Send(request.LoadFromEmrCommand, HttpContext.RequestAborted));
            var mpiExtractsTask = Task.Run(() => _mediator.Send(request.ExtractMpi, HttpContext.RequestAborted));
            var extractTasks    = new List <Task <bool> > {
                mpiExtractsTask, dwhExtractsTask
            };
            // wait for both tasks but doesn't throw an error for mpi load
            var result1 = await Task.WhenAll(extractTasks);

            return(Ok(dwhExtractsTask));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Load([FromBody] LoadExtracts request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (!request.LoadMpi)
            {
                var result = await _mediator.Send(request.LoadFromEmrCommand, HttpContext.RequestAborted);

                return(Ok(result));
            }

            var dwhExtractsTask = Task.Run(() => _mediator.Send(request.LoadFromEmrCommand, HttpContext.RequestAborted));
            var mpiExtractsTask = Task.Run(() => _mediator.Send(request.ExtractMpi, HttpContext.RequestAborted));
            var extractTasks    = new List <Task <bool> > {
                mpiExtractsTask, dwhExtractsTask
            };
            // wait for both tasks but doesn't throw an error for mpi load
            var result1 = await Task.WhenAll(extractTasks);

            return(Ok(dwhExtractsTask));
        }