Пример #1
0
        public ActionResult SendWorkerScreeningResults([FromBody] CompletedWorkerScreening result)
        {
            List <CompletedWorkerScreening> payload = new List <CompletedWorkerScreening>()
            {
                result
            };

            //Send the result to CARLA
            BackgroundJob.Enqueue(() => new CarlaUtils(Configuration, _loggerFactory, _sharepoint).SendWorkerScreeningResult(payload));
            _logger.LogInformation($"Started send Worker Screening result for job: {result.RecordIdentifier}");
            return(Ok());
        }
Пример #2
0
        public async Task ProcessWorkerResults(PerformContext hangfireContext)
        {
            string[] select       = { "incidentid" };
            string   workerFilter = $"spice_workersreadyforlcrb eq {(int)ReadyForLCRBStatus.ReadyForLCRB} and spice_cannabisapplicanttype eq {(int)CannabisApplicantType.Worker} and statecode eq 1 and statuscode eq 5";
            MicrosoftDynamicsCRMincidentCollection resp = _dynamicsClient.Incidents.Get(filter: workerFilter, select: select);

            if (resp.Value.Count == 0)
            {
                hangfireContext.WriteLine("No completed worker screenings found.");
                _logger.LogInformation("No completed worker screenings found.");
                return;
            }
            CarlaUtils carlaUtils = new CarlaUtils(Configuration, _loggerFactory, null);

            hangfireContext.WriteLine($"Found {resp.Value.Count} resolved worker screenings.");
            _logger.LogInformation($"Found {resp.Value.Count} resolved worker screenings.");
            foreach (MicrosoftDynamicsCRMincident incident in resp.Value)
            {
                CompletedWorkerScreening screening = GenerateCompletedWorkerScreening(incident.Incidentid);
                hangfireContext.WriteLine($"Sending worker screening [{screening.RecordIdentifier}] to Carla.");
                _logger.LogError($"Sending worker screening [{screening.RecordIdentifier}] to Carla.");
                ToggleResolution(incident.Incidentid, false);
                bool statusSet = SetLCRBStatus(incident.Incidentid, (int)ReadyForLCRBStatus.SentToLCRB, isBusiness: false);
                if (statusSet)
                {
                    try
                    {
                        bool workerResultSendStatus = await carlaUtils.SendWorkerScreeningResult(new List <CompletedWorkerScreening>() { screening });

                        if (workerResultSendStatus)
                        {
                            statusSet = SetLCRBStatus(incident.Incidentid, (int)ReadyForLCRBStatus.ReceivedByLCRB, isBusiness: false);
                            ToggleResolution(incident.Incidentid, true);
                            hangfireContext.WriteLine($"Successfully sent completed worker screening request [LCRB Job Id: {screening.RecordIdentifier}] to Carla.");
                            _logger.LogError($"Successfully sent completed worker screening request [LCRB Job Id: {screening.RecordIdentifier}] to Carla.");
                        }
                        else
                        {
                            this.HandleSendToLCRBFail(incident.Incidentid, screening.RecordIdentifier);
                        }
                    }
                    catch (HttpOperationException httpOperationException)
                    {
                        this.HandleSendToLCRBFail(incident.Incidentid, screening.RecordIdentifier);
                    }
                }
                else
                {
                    this.HandleSendToLCRBFail(incident.Incidentid, screening.RecordIdentifier);
                }
            }
        }
Пример #3
0
        public CompletedWorkerScreening GenerateCompletedWorkerScreening(string incidentId)
        {
            string[] expand = { "customerid_contact" };
            string[] select = { "customerid_contact", "incidentid", "spice_applicationstatus" };
            MicrosoftDynamicsCRMincident incident = _dynamicsClient.Incidents.GetByKey(incidentId, expand: expand, select: select);

            CompletedWorkerScreening screening = new CompletedWorkerScreening()
            {
                RecordIdentifier = incident.CustomeridContact.Externaluseridentifier,
                ScreeningResult  = SpiceApplicationStatusMapper.MapToCarlaWorkerResult((SpiceApplicationStatus)incident.SpiceApplicationstatus).ToString(),
                Worker           = new Lclb.Cllb.Interfaces.Models.Worker()
                {
                    FirstName  = incident.CustomeridContact.Firstname,
                    MiddleName = incident.CustomeridContact.Middlename,
                    LastName   = incident.CustomeridContact.Lastname
                }
            };

            return(screening);
        }