public void Execute() { var applicantsProvider = new JobApplicationProvider(); var reviewerProvider = new ReviewerProvider(); var configs = AppConfigsProvider.EscalationConfigs; Reviewer reviewer = null; var unhandledApplicants = applicantsProvider .GetList(a => a.ReviewStatus == Models.ReviewStatus.Assigned && a.RemindCount >= configs.RemindTheshold); if (unhandledApplicants.Count() == 0) { return; } foreach (var applicant in unhandledApplicants) { if (applicant.ReviewerId.HasValue) { reviewer = reviewerProvider.Get(applicant.ReviewerId.Value); } var email = new TimeOutApplicationEscalationEmail() { JobApplication = applicant, Reviewer = reviewer, EscalationTo = configs.ReportToEmails, }; BackgroundEmailService.Create().Send(email); _logger.InfoFormat("Reviewing for applicant {0} has been escalated as reviewer {1} did not finish his review after {2} of reminds", applicant.Id, reviewer.Id, applicant.RemindCount); } }
public ActionResult Edit(int id) { var service = new ReviewerProvider(); var reviewer = service.Get(id); if (reviewer == null) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound)); } return(View(reviewer)); }
public ActionResult Index(string order) { var jobApplicantService = new JobApplicationProvider(); var reviewerResourceServuce = new ReviewerProvider(); var results = jobApplicantService.GetList().OrderByDescending(m => m.AppliedAt) .Select(applicant => new ApplicantViewModel() { Applicant = applicant, Reviewer = applicant.ReviewerId.HasValue ? reviewerResourceServuce.Get(applicant.ReviewerId.Value) : null }); return(View(results)); }
public ActionResult SyncData() { var count = 0; var reviewerProvider = new ReviewerProvider(); var message = new MessageViewModel(); var usersGreenhouse = greenHouseAPI.GetUsers(); if (usersGreenhouse == null || usersGreenhouse.Count == 0) { message.Type = MessageType.Error; message.Title = "Not Found"; message.Content = "There're not data found vie GreenHouse API "; TempData["Message"] = message; return(RedirectToAction("Index")); } foreach (var user in usersGreenhouse) { var reviewer = reviewerProvider.Get(int.Parse(user.Id)); if (reviewer != null) { continue; } reviewer = new Reviewer() { Id = int.Parse(user.Id), Name = user.Name, Email = string.Join(";", user.Emails), }; reviewerProvider.Add(reviewer); count++; } if (count == 0) { message.Type = MessageType.Info; message.Title = "Finished"; message.Content = string.Format("No more updates found...", count); } else { message.Type = MessageType.Success; message.Title = "Success"; message.Content = string.Format("Added new {0} reviewer(s)...", count); } TempData["Message"] = message; return(RedirectToAction("Index")); }
public void Execute() { var applicantsProvider = new JobApplicationProvider(); var commonConfigs = AppConfigsProvider.CommonConfigs; var remindConfigs = AppConfigsProvider.RemindReviewersConfigs; var reviewerProvider = new ReviewerProvider(); //var greenHouseApi = DiContainers.Global.Resolve<IWebApiClient>(); var applicants = GetTimeOutApplicants(); var ghStore = GreenHouseDataStore.Instance; if (applicants.Count() == 0) { return; } Reviewer reviewer = null; foreach (var applicant in applicants) { if (applicant.ReviewerId.HasValue) { reviewer = reviewerProvider.Get(applicant.ReviewerId.Value); } if (reviewer == null) { applicant.ReviewStatus = ReviewStatus.Error; applicantsProvider.Update(applicant); continue; } if (!reviewer.IsInWorkingHours(commonConfigs.StartTimeOfDay, commonConfigs.EndTimeOfDay, commonConfigs.EnabledDays)) { _logger.InfoFormat("Don't remind reviewer {0} ({1} because he's not in working hour", reviewer.Id, reviewer.Name); continue; } applicant.RemindCount++; applicant.RecentRemindAt = DateTime.UtcNow; applicantsProvider.Update(applicant); var email = new RemindReviewApplicationEmail() { JobApplication = applicant, Reviewer = reviewer, Job = ghStore.GetJobById(applicant.JobId) }; BackgroundEmailService.Create().Send(email); } }
public ActionResult Delete(int id) { var service = new ReviewerProvider(); return(View(service.Get(id))); }
private void ProcUpdate(JobApplication applicant) { var applicantsProvider = new JobApplicationProvider(); var reviewerProvider = new ReviewerProvider(); var ghStore = GreenHouseDataStore.Instance; Reviewer reviewer = null; if (applicant == null || applicant.Id == 0) { return; } var apiJobApplication = ghStore.GetApplicationById(applicant.Id.ToString()); var appliedJob = ghStore.GetJobById(applicant.JobId); if (applicant.ReviewerId.HasValue) { reviewer = reviewerProvider.Get(applicant.ReviewerId.Value); } //applicant deleted if (apiJobApplication == null || apiJobApplication.Id == 0) { applicant.ReviewStatus = Models.ReviewStatus.Deleted; applicantsProvider.Update(applicant); _logger.WarnFormat("Applicant {0} has been deleted from Greenhosue", applicant.Id); return; } if (apiJobApplication.CurrentStage == null) { applicant.ReviewStatus = ReviewStatus.Error; applicantsProvider.Update(applicant); _logger.WarnFormat("Cant not resolve current stage for applicant {0}", applicant.Id); return; } //applicant accepted and moved to another stage if (apiJobApplication.CurrentStage.Name != ApplicationStages.ApplicationReviewCV) { applicant.ReviewStatus = ReviewStatus.Accepted; applicant.RejectedOrAcceptedAt = apiJobApplication.AcceptedAt; applicantsProvider.Update(applicant); if (reviewer != null) { reviewer.AdvanceCount++; reviewerProvider.Update(reviewer); } _logger.WarnFormat("Applicant {0} has been accepted and moved to next stage by reviewer {1}", applicant.Id, reviewer != null ? reviewer.Id : 0); } //applicant is still at CV / Review stage and was rejected if (apiJobApplication.CurrentStage.Name == ApplicationStages.ApplicationReviewCV && apiJobApplication.RejectedAt.HasValue) { applicant.ReviewStatus = ReviewStatus.Rejected; applicant.RejectAt = apiJobApplication.RejectedAt.Value; applicant.RejectedOrAcceptedAt = apiJobApplication.RejectedAt.Value; applicant.RejectionReason = apiJobApplication.RejectionReason; applicantsProvider.Update(applicant); if (reviewer != null) { reviewer.RejectCount++; reviewerProvider.Update(reviewer); } _logger.WarnFormat("Applicant {0} has been rejected by reviewer {1}", applicant.Id, reviewer?.Id ?? 0); } //Applied job was removed or closed if (appliedJob == null || appliedJob.Status != JobStates.Open) { applicant.ReviewStatus = ReviewStatus.JobClosed; applicantsProvider.Update(applicant); _logger.WarnFormat("Applicant {0} has been closed because its job {1} is either deleted or closed", applicant.Id, applicant.JobId); } }