Example #1
0
        protected void SavedResumeSearchAlertsRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var savedResumeSearchId = new Guid(e.CommandArgument.ToString());
            var savedResumeSearch   = MemberSearchesQuery.GetMemberSearch(savedResumeSearchId);

            try
            {
                SearchHelper.EnsureEmployerIsJobPoster(LoggedInUserId.Value, savedResumeSearch);
            }
            catch (UserException ex)
            {
                AddError(ex.Message);
                return;
            }

            switch (e.CommandName)
            {
            case null:
                break;

            case "Remove":
                MemberSearchAlertsCommand.DeleteMemberSearchAlert(LoggedInUser, savedResumeSearch, AlertType.Email);
                BindSavedResumeSearchAlertsRepeater();

                if (_items != null && _items.Count > 0)
                {
                    AddConfirm("The search \"" + savedResumeSearch.GetDisplayHtml() + "\" has been removed.", false);
                }

                break;

            default:
                break;
            }
        }
Example #2
0
        public ActionResult Saved(Guid savedSearchId)
        {
            var search = _memberSearchesQuery.GetMemberSearch(savedSearchId);

            if (search == null)
            {
                return(NotFound("search", "id", savedSearchId));
            }

            var employer = CurrentEmployer;

            ResetSearch(employer, search.Name);

            // Do a search based on the search's criteria.

            var criteria = search.Criteria;

            PrepareCriteria(employer, criteria);

            var searchList = Search(
                SearchContext.Saved,
                employer,
                null,
                criteria,
                PreparePresentationModel(null),
                savedSearchId);

            searchList.SavedSearch = search.Name;

            return(View("Results", searchList));
        }
Example #3
0
        public AjaxResult GetMemberSearchDisplayHtml(string memberSearchIdStr)
        {
            if (string.IsNullOrEmpty(memberSearchIdStr))
            {
                throw new ArgumentException("The member search ID must be specified.", "memberSearchIdStr");
            }

            try
            {
                EnsureEmployerLoggedIn();
                var memberSearch = _memberSearchesQuery.GetMemberSearch(new Guid(memberSearchIdStr));
                return(new AjaxResult(AjaxResultCode.SUCCESS, memberSearch.GetDisplayHtml()));
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }
        }
        public void Test0JobsToSearch()
        {
            // Create a search alert with JobsToSearch = 0.

            CreateMember(JobTitle);
            var employer = CreateEmployer();
            var search   = CreateSearchAlert(employer, 1, new MemberSearchCriteria {
                JobTitle = JobTitle, JobTitlesToSearch = 0, SortCriteria = new MemberSearchSortCriteria {
                    SortOrder = MemberSortOrder.DateUpdated
                }
            });

            // Run the task.

            Assert.AreEqual(JobsToSearch.AllJobs, _memberSearchesQuery.GetMemberSearch(search.Id).Criteria.JobTitlesToSearch);
            ExecuteTask();
            AssertEmail(employer, JobTitle);
        }
Example #5
0
 MemberSearch IMemberSearchAlertsQuery.GetMemberSearch(Guid ownerId, string name)
 {
     return(_memberSearchesQuery.GetMemberSearch(ownerId, name));
 }
Example #6
0
        private void ExecuteSearchAlerts(IList <MemberSearchAlert> alerts)
        {
            const string method = "ExecuteSearchAlerts";

            EventSource.Raise(Event.Information, method, string.Format("Processing {0} saved resume searches...", alerts.Count));

            var errors = 0;

            for (var index = 0; index < alerts.Count; index++)
            {
                // Primitive progress indicator.

                if (index % 200 == 0 && index > 0)
                {
                    EventSource.Raise(Event.Information, method, string.Format("Processed {0} out of {1} resume search alerts so far...", index, alerts.Count));
                }

                // Get the search.

                var alert = alerts[index];

                try
                {
                    var search = _memberSearchesQuery.GetMemberSearch(alert.MemberSearchId);
                    if (search.Criteria == null)
                    {
                        // Handle failures in loading search criteria.

                        EventSource.Raise(Event.Error, method, string.Format("Search criteria was NULL for saved resume search {0}." + " See earlier log messages for details.", search.Id));
                        errors++;
                    }
                    else
                    {
                        // Only send if the owner is enabled.

                        var employer = _employersQuery.GetEmployer(search.OwnerId);
                        if (employer.IsEnabled)
                        {
                            // Get the criteria text before the search is done, so the user doesn't get a huge list of synonyms inserted.

                            var lastRunTime = alert.LastRunTime;
                            var results     = GetResults(employer, search, alert);

                            EventSource.Raise(Event.Trace, method, string.Format("Resume alert for user {0:b} returned {1} results. Modified since: {2} Criteria: {3}", search.OwnerId, results == null ? "no" : results.MemberIds.Count.ToString(), lastRunTime, search.Criteria));

                            if (results != null && results.MemberIds.Count > 0)
                            {
                                Alert(employer, search, alert, results);
                                _alertsSent++;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    EventSource.Raise(Event.Error, method, string.Format("Failed to execute search or send alert for resume search alert {0}.", alert.Id.ToString("B")), ex, new StandardErrorHandler());
                    errors++;
                }
            }

            ReportResults(alerts.Count, errors);
        }