示例#1
0
        bool IExternalJobAdsCommand.CanCreateJobAd(JobAdEntry jobAd)
        {
            var equivalentJobAds = GetEquivalentJobAds(jobAd);

            if (equivalentJobAds.Count == 0)
            {
                return(true);
            }

            // The job ads must be either Draft or Open.

            equivalentJobAds = (from j in equivalentJobAds where j.Status == JobAdStatus.Draft || j.Status == JobAdStatus.Open select j).ToList();
            if (equivalentJobAds.Count == 0)
            {
                return(true);
            }

            // If it has higher priority then any of the equivalent job ads then ...

            if (HasHigherPriority(jobAd, equivalentJobAds))
            {
                // Then close those equivalent job ads so this job ad can replace them.

                foreach (var equivalentJobAd in equivalentJobAds)
                {
                    _jobAdsCommand.CloseJobAd(equivalentJobAd);
                }
                return(true);
            }

            return(false);
        }
示例#2
0
        CloseReport IJobAdPostsManager.CloseJobAds(Guid integratorUserId, IEmployer jobPoster, IEnumerable <string> externalReferenceIds)
        {
            var report = new CloseReport();

            // Read the existing job ads for this integrator/job poster combination.

            var existingJobAdIds = GetExistingJobAdIds(integratorUserId, jobPoster.Id);

            // Find which of the specified job ad external IDs exist and close those.

            var externalReferenceIdList = externalReferenceIds.ToList();
            var jobAdIds = FilterJobAdIds(externalReferenceIdList, existingJobAdIds, report);

            if (jobAdIds.Count > 0)
            {
                var jobAds = _jobAdsQuery.GetJobAds <JobAd>(jobAdIds);
                foreach (var jobAd in jobAds)
                {
                    if (_jobAdsCommand.CanBeClosed(jobAd))
                    {
                        _jobAdsCommand.CloseJobAd(jobAd);
                    }
                }
            }

            // Fill in the report.

            report.Closed = jobAdIds.Count;
            report.Failed = externalReferenceIdList.Count - jobAdIds.Count;

            return(report);
        }
示例#3
0
        private void CloseExpiredJobAds()
        {
            const string method = "CloseExpiredJobAds";

            EventSource.Raise(Event.Information, method, "Closing expired job ads");

            var ids   = _jobAdsQuery.GetExpiredJobAdIds();
            var count = 0;

            foreach (var id in ids)
            {
                try
                {
                    var jobAd = _jobAdsQuery.GetJobAd <JobAd>(id);
                    if (jobAd != null)
                    {
                        _jobAdsCommand.CloseJobAd(jobAd);
                        ++count;
                    }
                }
                catch (Exception ex)
                {
                    EventSource.Raise(Event.Error, method, string.Format("Could not close the '{0}' job ad.", id), ex);
                }
            }

            EventSource.Raise(Event.Information, method, string.Format("{0} expired job ads were closed.", count));
        }
示例#4
0
        private JobAd CreateJobAd(IHasId <Guid> employer, JobAdStatus status)
        {
            var jobAd = new JobAd
            {
                Id          = Guid.NewGuid(),
                Status      = status,
                Title       = "Best Job in the World",
                CreatedTime = DateTime.Now,
                PosterId    = employer.Id,
                Description =
                {
                    BulletPoints = new[]               { "good verbal communication", "self management and independency", "bullet point 3" },
                    Content      = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.",
                    JobTypes     = JobTypes.FullTime,
                    Industries   = new List <Industry> {
                        _industriesQuery.GetIndustry("Engineering")
                    },
                },
            };

            _jobAdsCommand.CreateJobAd(jobAd);
            _jobAdsCommand.OpenJobAd(jobAd);
            if (status == JobAdStatus.Closed)
            {
                _jobAdsCommand.CloseJobAd(jobAd);
            }
            return(jobAd);
        }
示例#5
0
        private void TestResults <T>(bool createReport, Func <Guid, IOrganisation> createOrganisation, Action <Administrator, IOrganisation, EmployerReport> test)
            where T : EmployerReport
        {
            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var organisation  = createOrganisation(administrator.Id);
            var employer      = _employerAccountsCommand.CreateTestEmployer(1, organisation);
            var member        = _memberAccountsCommand.CreateTestMember(1);

            if (typeof(T) == typeof(ResumeSearchActivityReport))
            {
                _employerMemberViewsCommand.ViewMember(_app, employer, member);
            }
            else if (typeof(T) == typeof(JobBoardActivityReport))
            {
                var jobAd = _jobAdsCommand.PostTestJobAd(employer);
                _jobAdViewsCommand.ViewJobAd(Guid.NewGuid(), jobAd.Id);
                var application = new InternalApplication {
                    ApplicantId = Guid.NewGuid()
                };
                _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application);
                _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application);
                _jobAdsCommand.CloseJobAd(jobAd);
            }

            var report = _employerReportsCommand.CreateReportTemplate <T>(organisation.Id);

            if (createReport)
            {
                _employerReportsCommand.CreateReport(report);
            }
            test(administrator, organisation, report);
        }
示例#6
0
        private static JobAd PostTestJobAd(this IJobAdsCommand jobAdsCommand, JobAd jobAd, JobAdStatus jobStatus)
        {
            jobAdsCommand.CreateJobAd(jobAd);
            switch (jobStatus)
            {
            case JobAdStatus.Open:
                jobAdsCommand.OpenJobAd(jobAd);
                break;

            case JobAdStatus.Closed:
                jobAdsCommand.OpenJobAd(jobAd);
                jobAdsCommand.CloseJobAd(jobAd);
                break;

            case JobAdStatus.Deleted:
                jobAdsCommand.DeleteJobAd(jobAd);
                break;

            default:
                //do nothing - job is created in draft state
                break;
            }

            return(jobAd);
        }
示例#7
0
        private void CreateNewJobAd(string adContent, JobAdStatus adStatus, IHasId <Guid> adPoster,
                                    bool adHideContactDetails, ContactDetails adContactDetails, string summary, string bulletpoint1, string bulletpoint2,
                                    string bulletpoint3, FileReference logoImg, string adTitle, string positionTitle,
                                    JobTypes jobtypes, bool isResidenacyRequired, string externalRef, decimal?maxsalary,
                                    decimal?minsalary, string package, IList <Industry> reqIndustries, string companyname,
                                    LocationReference jobLocation, DateTime expiryDate)
        {
            var bulletPoints = new[] { bulletpoint1, bulletpoint2, bulletpoint3 };

            var newJobAd = new JobAd
            {
                Status     = adStatus,
                PosterId   = adPoster.Id,
                Visibility =
                {
                    HideContactDetails = adHideContactDetails,
                    HideCompany        = false,
                },
                ContactDetails = adContactDetails,
                Title          = adTitle,
                Integration    = { ExternalReferenceId = externalRef },
                LogoId         = logoImg == null ? (Guid?)null : logoImg.Id,
                ExpiryTime     = expiryDate,
                Description    =
                {
                    CompanyName       = companyname,
                    Content           = adContent,
                    PositionTitle     = positionTitle,
                    ResidencyRequired = isResidenacyRequired,
                    JobTypes          = jobtypes,
                    Industries        = reqIndustries,
                    Summary           = summary,
                    Salary            = (minsalary.HasValue || maxsalary.HasValue
                        ? new Salary
                    {
                        Currency      = Currency.AUD,
                        LowerBound    = minsalary,
                        UpperBound    = maxsalary,
                        Rate          = SalaryRate.Year,
                    }
                        : null),
                    Package      = package,
                    BulletPoints = bulletPoints,
                    Location     = jobLocation,
                }
            };

            _jobAdsCommand.CreateJobAd(newJobAd);

            if (adStatus == JobAdStatus.Open)
            {
                _jobAdsCommand.OpenJobAd(newJobAd);
            }
            else if (adStatus == JobAdStatus.Closed)
            {
                _jobAdsCommand.CloseJobAd(newJobAd);
            }

            return;
        }
示例#8
0
 void IEmployerJobAdsCommand.CloseJobAd(IEmployer employer, JobAdEntry jobAd)
 {
     if (!CanAccess(employer, jobAd))
     {
         throw new JobAdPermissionsException(employer, jobAd.Id);
     }
     _jobAdsCommand.CloseJobAd(jobAd);
 }
示例#9
0
        private void CloseJobAds(Guid posterId, IDictionary <Guid, bool> hasCredits)
        {
            if (HasApplicantCredits(posterId, hasCredits))
            {
                return;
            }

            // No active allocations so close all their job ads.

            var jobAdIds = _jobAdsQuery.GetOpenJobAdIds(posterId);
            var jobAds   = _jobAdsQuery.GetJobAds <JobAd>(jobAdIds);

            foreach (var jobAd in jobAds)
            {
                _jobAdsCommand.CloseJobAd(jobAd);
            }
        }
示例#10
0
        public void TestGetExpiredJobAds()
        {
            var employer = CreateEmployer();

            // Create an open job ad.

            var activeJobAd = _jobAdsCommand.PostTestJobAd(employer);

            // Create an open job ad that has expired.

            var expiredJobAd = employer.CreateTestJobAd();

            _jobAdsCommand.PostJobAd(expiredJobAd);
            expiredJobAd.ExpiryTime = DateTime.Now.AddDays(-1);
            _jobAdsCommand.UpdateJobAd(expiredJobAd);

            Assert.AreEqual(JobAdStatus.Open, activeJobAd.Status);
            Assert.AreEqual(JobAdStatus.Open, expiredJobAd.Status);

            // Get the expired job ads.

            var ids = _jobAdsQuery.GetExpiredJobAdIds();

            Assert.AreEqual(1, ids.Count);
            Assert.AreEqual(expiredJobAd.Id, ids[0]);

            // Close them.

            foreach (var id in ids)
            {
                var closeJobAd = _jobAdsQuery.GetJobAd <JobAdEntry>(id);
                _jobAdsCommand.CloseJobAd(closeJobAd);
            }

            // Check the status.

            var jobAd = _jobAdsCommand.GetJobAd <JobAdEntry>(activeJobAd.Id);

            Assert.AreEqual(JobAdStatus.Open, jobAd.Status);
            jobAd = _jobAdsCommand.GetJobAd <JobAdEntry>(expiredJobAd.Id);
            Assert.AreEqual(JobAdStatus.Closed, jobAd.Status);

            // Do it again.

            Assert.AreEqual(0, _jobAdsQuery.GetExpiredJobAdIds().Count);
        }
示例#11
0
        public void TestGetOpenJobAds()
        {
            var employer = CreateEmployer(1);

            _jobAdsCommand.PostTestJobAd(employer);
            _jobAdsCommand.PostTestJobAd(employer);
            Assert.AreEqual(2, _jobAdReportsQuery.GetOpenJobAds());

            // Create another.

            var closedJobAd = _jobAdsCommand.PostTestJobAd(employer);

            Assert.AreEqual(3, _jobAdReportsQuery.GetOpenJobAds());

            // Close it.

            _jobAdsCommand.CloseJobAd(closedJobAd);
            Assert.AreEqual(2, _jobAdReportsQuery.GetOpenJobAds());
        }
示例#12
0
        private static JobAd PostTestJobAd(this IJobAdsCommand jobAdsCommand, JobAd jobAd, JobAdStatus jobStatus)
        {
            jobAdsCommand.CreateJobAd(jobAd);
            switch (jobStatus)
            {
            case JobAdStatus.Open:
                jobAdsCommand.OpenJobAd(jobAd);
                break;

            case JobAdStatus.Closed:
                jobAdsCommand.OpenJobAd(jobAd);
                jobAdsCommand.CloseJobAd(jobAd);
                break;

            case JobAdStatus.Deleted:
                jobAdsCommand.DeleteJobAd(jobAd);
                break;
            }

            return(jobAd);
        }
示例#13
0
        public void TestRefreshJobAds()
        {
            var employer = CreateEmployer();
            var jobAd1   = PostRefreshJobAd(employer, DateTime.Now.AddDays(-20), null);
            var jobAd2   = PostRefreshJobAd(employer, DateTime.Now.AddDays(-20), DateTime.Now.AddDays(-4));
            var jobAd3   = PostRefreshJobAd(employer, DateTime.Now.AddDays(-20), null);
            var jobAd4   = PostRefreshJobAd(employer, DateTime.Now.AddDays(-20), DateTime.Now.AddDays(-20));
            var jobAd5   = PostRefreshJobAd(employer, DateTime.Now.AddDays(-20), DateTime.Now.AddDays(-8));

            Assert.AreEqual(null, _jobAdsQuery.GetLastRefreshTime(jobAd1.Id));
            var lastRefreshTime2 = _jobAdsQuery.GetLastRefreshTime(jobAd2.Id);

            Assert.IsNotNull(lastRefreshTime2);
            Assert.AreEqual(DateTime.Now.AddDays(-4).Date, lastRefreshTime2.Value.Date);
            Assert.AreEqual(null, _jobAdsQuery.GetLastRefreshTime(jobAd3.Id));
            var lastRefreshTime4 = _jobAdsQuery.GetLastRefreshTime(jobAd4.Id);

            Assert.IsNotNull(lastRefreshTime4);
            Assert.AreEqual(DateTime.Now.AddDays(-20).Date, lastRefreshTime4.Value.Date);
            var lastRefreshTime5 = _jobAdsQuery.GetLastRefreshTime(jobAd5.Id);

            Assert.IsNotNull(lastRefreshTime5);
            Assert.AreEqual(DateTime.Now.AddDays(-8).Date, lastRefreshTime5.Value.Date);

            new UpdateJobAdsTask(_jobAdsCommand, _jobAdsQuery).ExecuteTask();

            Assert.AreEqual(null, _jobAdsQuery.GetLastRefreshTime(jobAd1.Id));
            lastRefreshTime2 = _jobAdsQuery.GetLastRefreshTime(jobAd2.Id);
            Assert.IsNotNull(lastRefreshTime2);
            Assert.AreEqual(DateTime.Now.AddDays(-4).Date, lastRefreshTime2.Value.Date);
            Assert.AreEqual(null, _jobAdsQuery.GetLastRefreshTime(jobAd3.Id));
            lastRefreshTime4 = _jobAdsQuery.GetLastRefreshTime(jobAd4.Id);
            Assert.IsNotNull(lastRefreshTime4);
            Assert.AreEqual(DateTime.Now.Date, lastRefreshTime4.Value.Date);
            lastRefreshTime5 = _jobAdsQuery.GetLastRefreshTime(jobAd5.Id);
            Assert.IsNotNull(lastRefreshTime5);
            Assert.AreEqual(DateTime.Now.Date, lastRefreshTime5.Value.Date);

            new UpdateJobAdsTask(_jobAdsCommand, _jobAdsQuery).ExecuteTask();

            Assert.AreEqual(null, _jobAdsQuery.GetLastRefreshTime(jobAd1.Id));
            lastRefreshTime2 = _jobAdsQuery.GetLastRefreshTime(jobAd2.Id);
            Assert.IsNotNull(lastRefreshTime2);
            Assert.AreEqual(DateTime.Now.AddDays(-4).Date, lastRefreshTime2.Value.Date);
            Assert.AreEqual(null, _jobAdsQuery.GetLastRefreshTime(jobAd3.Id));
            lastRefreshTime4 = _jobAdsQuery.GetLastRefreshTime(jobAd4.Id);
            Assert.IsNotNull(lastRefreshTime4);
            Assert.AreEqual(DateTime.Now.Date, lastRefreshTime4.Value.Date);
            lastRefreshTime5 = _jobAdsQuery.GetLastRefreshTime(jobAd5.Id);
            Assert.IsNotNull(lastRefreshTime5);
            Assert.AreEqual(DateTime.Now.Date, lastRefreshTime5.Value.Date);

            _jobAdsCommand.CloseJobAd(jobAd4);

            Assert.AreEqual(null, _jobAdsQuery.GetLastRefreshTime(jobAd1.Id));
            lastRefreshTime2 = _jobAdsQuery.GetLastRefreshTime(jobAd2.Id);
            Assert.IsNotNull(lastRefreshTime2);
            Assert.AreEqual(DateTime.Now.AddDays(-4).Date, lastRefreshTime2.Value.Date);
            Assert.AreEqual(null, _jobAdsQuery.GetLastRefreshTime(jobAd3.Id));
            Assert.AreEqual(null, _jobAdsQuery.GetLastRefreshTime(jobAd4.Id));
            lastRefreshTime5 = _jobAdsQuery.GetLastRefreshTime(jobAd5.Id);
            Assert.IsNotNull(lastRefreshTime5);
            Assert.AreEqual(DateTime.Now.Date, lastRefreshTime5.Value.Date);
        }
示例#14
0
 protected void CloseJobAd(JobAd jobAd)
 {
     _jobAdsCommand.CloseJobAd(jobAd);
 }
示例#15
0
        public DeleteAdvertResponseMessage DeleteAdvert(DeleteAdvertRequestMessage request)
        {
            const string method = "DeleteAdvert";

            EventSource.Raise(Event.Information, method, Event.Arg("request", request));

            IntegratorUser integratorUser;
            IEmployer      jobPoster;

            CheckUser(request.UserCredentials, out integratorUser, out jobPoster);

            var errors = new List <string>();
            var report = new DeleteAdvertReport();

            foreach (var deleteAd in request.DeleteAdvert.Adverts.DeleteAdvert)
            {
                report.JobAds++;

                try
                {
                    var ids    = _jobAdIntegrationQuery.GetJobAdIds(integratorUser.Id, deleteAd.JobReference);
                    var jobAds = _jobAdsQuery.GetJobAds <JobAd>(ids);
                    foreach (var jobAd in jobAds)
                    {
                        _jobAdsCommand.CloseJobAd(jobAd);
                    }
                    var closed = ids.Count;

                    if (closed > 0)
                    {
                        report.Closed += closed;
                    }
                    else
                    {
                        var message = string.Format("Job ad to be deleted, '{0}', was not found.", deleteAd.JobReference);
                        EventSource.Raise(Event.Error, method, message, Event.Arg("deleteAd", deleteAd));
                        errors.Add(message);
                        report.NotFound++;
                    }
                }
                catch (ServiceEndUserException e)
                {
                    EventSource.Raise(Event.Error, method, e, null, Event.Arg("postAd", deleteAd));
                    errors.Add(string.Format("JobReference='{0}': {1}", deleteAd.JobReference, e.Message));
                    report.Failed++;
                }
                catch (Exception e)
                {
                    EventSource.Raise(Event.Error, method, e, null, Event.Arg("postAd", deleteAd));
                    errors.Add(string.Format("JobReference='{0}': Unexpected error.", deleteAd.JobReference));
                    report.Failed++;
                }
            }

            // Record it.

            _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdImportCloseEvent {
                IntegratorUserId = integratorUser.Id, Success = true, JobAds = report.JobAds, Closed = report.Closed, Failed = report.Failed, NotFound = report.NotFound
            });

            var response = new DeleteAdvertResponseMessage
            {
                DeleteAdvertResponse = new Response {
                    Success = string.Join("\r\n", errors.ToArray())
                }
            };

            EventSource.Raise(Event.Information, method, string.Format("{0} ads processed; {1} ads deleted, {2} ads not found, {3} errors.", report.JobAds, report.Closed, report.NotFound, report.Failed), Event.Arg("response", response));
            return(response);
        }
示例#16
0
        public void TestCloseJobAd()
        {
            var member = CreateMember();
            var folder = _jobAdFoldersQuery.GetFolders(member)[0];

            var searchQuery = new JobAdSearchQuery {
                AdTitle = Expression.Parse(Title)
            };
            var sortQuery = new JobAdSortQuery();

            // Add a job ad.

            var employer = CreateEmployer();

            LogIn(employer);
            Get(_newJobAdUrl);
            CreateJobAd(employer.EmailAddress.Address);
            _previewButton.Click();
            _publishButton.Click();
            LogOut();

            // Add it to the folder.

            var jobAd = _jobAdsQuery.GetJobAds <JobAdEntry>(_jobAdsQuery.GetJobAdIds(employer.Id, JobAdStatus.Open))[0];

            _memberJobAdListsCommand.AddJobAdToFolder(member, folder, jobAd.Id);

            // Wait for the polling to kick in.

            Thread.Sleep(3 * MonitorInterval * 1000);

            // Do some searches.

            var results = _searchService1.Search(null, searchQuery);

            Assert.AreEqual(1, results.JobAdIds.Count);
            Assert.AreEqual(jobAd.Id, results.JobAdIds[0]);

            results = _searchService2.Search(null, searchQuery);
            Assert.AreEqual(1, results.JobAdIds.Count);
            Assert.AreEqual(jobAd.Id, results.JobAdIds[0]);

            results = _sortService1.SortFolder(member.Id, folder.Id, sortQuery);
            Assert.AreEqual(1, results.JobAdIds.Count);
            Assert.AreEqual(jobAd.Id, results.JobAdIds[0]);

            results = _sortService2.SortFolder(member.Id, folder.Id, sortQuery);
            Assert.AreEqual(1, results.JobAdIds.Count);
            Assert.AreEqual(jobAd.Id, results.JobAdIds[0]);

            // Close the job ad.

            _jobAdsCommand.CloseJobAd(jobAd);

            // Do some searches again.

            results = _searchService1.Search(null, searchQuery);
            Assert.AreEqual(0, results.JobAdIds.Count);

            results = _sortService1.SortFolder(member.Id, folder.Id, sortQuery);
            Assert.AreEqual(1, results.JobAdIds.Count);
            Assert.AreEqual(jobAd.Id, results.JobAdIds[0]);

            // Wait for the polling to kick in.

            Thread.Sleep(3 * MonitorInterval * 1000);
            results = _searchService2.Search(null, searchQuery);
            Assert.AreEqual(0, results.JobAdIds.Count);

            results = _sortService2.SortFolder(member.Id, folder.Id, sortQuery);
            Assert.AreEqual(1, results.JobAdIds.Count);
            Assert.AreEqual(jobAd.Id, results.JobAdIds[0]);
        }