Exemplo n.º 1
0
        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 void Execute()
        {
            var report = new InterviewsEvaluationReportEmail();

            using (var dbContext = new AARPDbContext())
            {
                var lastDate = DateTime.Now.AddDays(-7);

                report.InterviewReportItems = (from i in dbContext.Interviews
                                               join ivr in dbContext.Interviewers on i.InterviewerId equals ivr.Id
                                               join iw in dbContext.Interviewees on i.IntervieweeId equals iw.Id
                                               join st in dbContext.InterviewStages on i.InterviewStageId equals st.Id
                                               join sn in dbContext.Seniorities on i.SeniorityId equals sn.Id
                                               where i.Date >= lastDate
                                               orderby i.Date descending
                                               select new EvaluationReportItem
                {
                    interview = i,
                    interviewee = iw,
                    interviewer = ivr,
                    seniority = sn,
                    stage = st
                }).ToList();
            }

            BackgroundEmailService.Create().Send(report);
        }
        private void SendAssignmentEmail(Reviewer to, JobApplication applicant, ApiJob job)
        {
            var email = new ReviewApplicationEmail()
            {
                Reviewer       = to,
                JobApplication = applicant,
                Job            = job,
            };

            BackgroundEmailService.Create().Send(email);
            System.Diagnostics.Trace.WriteLine("New review email has been sent to the reviewer {0}", email.Reviewer.Name);
        }
        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);
            }
        }
        private void SendEmailForReferral(JobApplication applicant, ApiJob job)
        {
            if (applicant == null || applicant.Source != ApplicantSources.Referral)
            {
                return;
            }
            var referralEmail = new NotificationOfNewReferralEmail()
            {
                Applicant = applicant,
                Job       = job,
                SendTo    = AppConfigsProvider.ReferralsHandlingConfigs.ReportToEmails
            };

            BackgroundEmailService.Create().Send(referralEmail);
        }
Exemplo n.º 6
0
        public void SendEvaluationInvitationEmail(int InterviewerID, int IntervieweeID)
        {
            using (var dbContext = new AARPDbContext())
            {
                var Interviewee = dbContext.Interviewees.Where(x => x.Id == IntervieweeID).First();
                var Interviewer = dbContext.Interviewers.Where(x => x.Id == InterviewerID).First();
                var email       = new EvaluationInvitationEmail()
                {
                    interviewer    = Interviewer,
                    interviewee    = Interviewee,
                    EvaluationLink = GenerateEvaluationLink(IntervieweeID, InterviewerID)
                };

                BackgroundEmailService.Create().Send(email);
            }
        }
        public void OnStateApplied(ApplyStateContext context, Hangfire.Storage.IWriteOnlyTransaction transaction)
        {
            var failedState = context.NewState as FailedState;

            if (failedState != null)
            {
                Logger.Error(
                    $"Background job #{context.BackgroundJob.Id} was failed with an exception.",
                    failedState.Exception);

                var configs = AppConfigsProvider.GetConfigs <AppConfigs.ReportErrorsConfig>();
                if (configs.IsEnabled)
                {
                    var email = new NotificationOfErrorEmail()
                    {
                        HangfireContext = context,
                        To = string.Join("; ", configs.ReportToEmails)
                    };
                    BackgroundEmailService.Create().Send(email);
                }
            }
        }