Exemplo n.º 1
0
        public static async Task HiringProcessOrchestrator(
            [OrchestrationTrigger] DurableOrchestrationContext context, ILogger logger)
        {
            JobApplication jobApplication = context.GetInput <JobApplication>();

            ProcessInterviewRoundInputModel processInterviewRoundOne = new ProcessInterviewRoundInputModel()
            {
                JobApplication         = jobApplication,
                RoundNumber            = 1,
                OrchestratorInstanceId = context.InstanceId
            };
            InterviewRoundResult IsRoundOnePassed = await context.CallSubOrchestratorAsync <InterviewRoundResult>("InterviewRoundOrchestrator", processInterviewRoundOne);


            if (IsRoundOnePassed.IsPassed)
            {
                logger.LogWarning($"{jobApplication.Name} has passed round one, scheduling round {processInterviewRoundOne.RoundNumber + 1}.");

                processInterviewRoundOne.RoundNumber += 1;
                InterviewRoundResult IsRoundTwoPaased = await context.CallSubOrchestratorAsync <InterviewRoundResult>("InterviewRoundOrchestrator", processInterviewRoundOne);

                if (IsRoundTwoPaased.IsPassed)
                {
                    /// Rollout offer
                    ///
                    await context.CallActivityAsync <Notification>("RollOutOffer", processInterviewRoundOne.JobApplication);

                    logger.LogWarning($"Offer rolled out to {processInterviewRoundOne.JobApplication.Name}.");

                    /// Wait for offer approval from candidate
                    /// External Event
                    bool IsOfferAccepted = await context.CallSubOrchestratorAsync <bool>("OfferOrchestrator", processInterviewRoundOne);

                    if (IsOfferAccepted)
                    {
                        /// Fan out processing
                        ///
                        bool finalResult = await context.CallSubOrchestratorAsync <bool>("ReadinessOrchestrator", processInterviewRoundOne.JobApplication);

                        if (finalResult)
                        {
                            logger.LogWarning($"Everything is ready for {processInterviewRoundOne.JobApplication.Name} {finalResult}");
                        }
                        else
                        {
                            logger.LogWarning($"Not all things are ready for {processInterviewRoundOne.JobApplication.Name} {finalResult}");
                        }
                    }
                }
            }
            await context.CallActivityAsync <Notification>("DeclineApplication", processInterviewRoundOne.JobApplication);
        }
Exemplo n.º 2
0
        public static async Task SubmitInterviewRoundResult(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "hr/interview")] HttpRequestMessage request,
            [OrchestrationClient] DurableOrchestrationClient durableOrchestrationClient,
            ILogger log)
        {
            string requestBody = await request.Content.ReadAsStringAsync();

            if (string.IsNullOrEmpty(requestBody))
            {
                throw new NullReferenceException();
            }


            InterviewRoundResult data = JsonConvert.DeserializeObject <InterviewRoundResult>(requestBody);

            await durableOrchestrationClient.RaiseEventAsync(data.OrchestratorInstanceId, "InterviewRoundResultSubmitted", data);
        }