Exemplo n.º 1
0
        void IAccountVerificationsCommand.StartActivationWorkflow(IRegisteredUser user)
        {
            // Only supported for members at the moment.

            var member = user as IMember;

            if (member == null)
            {
                return;
            }

            var service = _activationEmailManager.Create();

            try
            {
                service.StartSending(member.Id);
            }
            catch (Exception)
            {
                _activationEmailManager.Abort(service);
                throw;
            }

            _activationEmailManager.Close(service);
        }
Exemplo n.º 2
0
        void IUpdateMemberSearchCommand.ClearAll()
        {
            var service = _serviceManager.Create();

            try
            {
                service.Clear();
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);
        }
Exemplo n.º 3
0
        public void OnJobAdOpened(object sender, JobAdOpenedEventArgs e)
        {
            var channel = _channelManager.Create();

            try
            {
                channel.Add(e.JobAdId);
                _channelManager.Close(channel);
            }
            catch (Exception)
            {
                _channelManager.Abort(channel);
                throw;
            }
        }
Exemplo n.º 4
0
        string ISendJobG8Command.SendApplication(ICommunicationUser user, JobAdEntry jobAd, string resumeFileName, FileContents resumeContents, InternalApplication application, IEnumerable <ApplicationAnswer> answers)
        {
            var request = new UploadRequestMessage
            {
                Body = new UploadRequestBody
                {
                    ApplicationXml = Serialize(CreateApplicationResponse(user, jobAd, resumeFileName, resumeContents, application, answers))
                }
            };

            string result;
            var    service = _serviceManager.Create();

            try
            {
                var response = service.Send(request);
                result = response.Body.Result;
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);

            return(result);
        }
Exemplo n.º 5
0
        void ICandidateStatusCommand.ConfirmStatus(Guid candidateId, CandidateStatus status)
        {
            var service = _serviceFactory.Create();

            try
            {
                switch (status)
                {
                case CandidateStatus.ActivelyLooking:
                    service.OnActivelyLookingConfirmed(candidateId);
                    break;

                case CandidateStatus.AvailableNow:
                    service.OnAvailableNowConfirmed(candidateId);
                    break;
                }

                _serviceFactory.Close(service);
            }
            catch (Exception)
            {
                _serviceFactory.Abort(service);
                throw;
            }
        }
Exemplo n.º 6
0
        IList <SpellingSuggestion> IMemberSearchSuggestionsQuery.GetSpellingSuggestions(MemberSearchCriteria criteria)
        {
            var queryString = ToQueryString(criteria);

            SpellCheckCollation[] collations;
            var service = _serviceManager.Create();

            try
            {
                collations = service.GetSpellingSuggestions(queryString, _maxCollations);
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);

            var suggestions = new List <SpellingSuggestion>(collations.Length);

            foreach (var collation in collations)
            {
                var suggestedCriteria = criteria.Clone();
                ApplyQueryString(suggestedCriteria, collation.CollationQuery);

                suggestions.Add(new SpellingSuggestion
                {
                    Criteria    = suggestedCriteria,
                    Corrections = collation.MisspellingsAndCorrections
                });
            }

            return(suggestions);
        }
Exemplo n.º 7
0
        private JobAdSortExecution Sort(IHasId <Guid> member, JobAdSearchSortCriteria sortCriteria, Range range, Func <IJobAdSortService, Guid?, JobAdSortQuery, JobAdSearchResults> sort)
        {
            var criteria = new JobAdSortCriteria {
                SortCriteria = sortCriteria
            };

            JobAdSearchResults results;
            var service = _serviceManager.Create();

            try
            {
                results = sort(service, member == null ? (Guid?)null : member.Id, criteria.GetSortQuery(range));
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);

            return(new JobAdSortExecution
            {
                Criteria = criteria,
                Results = results,
            });
        }
Exemplo n.º 8
0
        private void UpdateJobAd(Guid jobAdId)
        {
            const string method = "UpdateJobAd";

            EventSource.Raise(Event.Trace, method, "Updating modification for job ad '" + jobAdId + "'.");

            // Update all search engines.

            _jobAdSearchEngineCommand.SetModified(jobAdId);

            // Make sure the local one is updated now.

            EventSource.Raise(Event.Trace, method, "Updating local search engine for job ad '" + jobAdId + "'.");

            var service = _serviceManager.Create();

            try
            {
                service.UpdateJobAd(jobAdId);
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);
        }
Exemplo n.º 9
0
        bool IExecuteMemberSearchCommand.IsSearchable(Guid memberId)
        {
            bool isIndexed;
            var  service = _serviceManager.Create();

            try
            {
                isIndexed = service.IsIndexed(memberId);
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);

            return(isIndexed);
        }
Exemplo n.º 10
0
        private void ExecuteTaskCore(int?count)
        {
            const string method = "ExecuteTaskCore";

            if (!ServiceAvailable())
            {
                Logger.Raise(Event.Information, method, "Processing delayed due to DEEWR service unavailability. Available times are M-F 0800-2300 and Sat 0900-1300.");
                return;
            }

            var excludedIntegratorIds = Array.ConvertAll(ExcludedIntegrators, GetIntegratorId);

            var jobAdIds = _jobAdIntegrationQuery.GetOpenJobAdIds(excludedIntegratorIds)
                           .Where(jobAdId => !IsPublished(jobAdId));

            if (count.HasValue && count.Value != 0)
            {
                jobAdIds = jobAdIds.Take(count.Value);
            }

            var channel = _channelManager.Create();

            #region Log
            var timer          = Stopwatch.StartNew();
            int processedCount = 0;
            Logger.Raise(Event.Information, method, "Processing started...");
            #endregion

            foreach (var jobAdId in jobAdIds)
            {
                try
                {
                    channel.Add(jobAdId);
                }
                catch (Exception)
                {
                    _channelManager.Abort(channel);
                    throw;
                }

                #region Log
                processedCount++;
                if (timer.ElapsedMilliseconds > _progressInterval)
                {
                    Logger.Raise(Event.Information, method, string.Format("{0} job ads exported...", processedCount));
                    timer.Reset();
                    timer.Start();
                }
                #endregion
            }

            #region Log
            Logger.Raise(Event.Information, method, string.Format("Processing complte. {0} job ads were exported.", processedCount));
            #endregion

            _channelManager.Close(channel);
        }
Exemplo n.º 11
0
        private void HandleStatusChanged(Guid candidateId, CandidateStatus status)
        {
            var proxy = _proxyManager.Create();

            try
            {
                proxy.OnStatusChanged(candidateId, status);
                _proxyManager.Close(proxy);
            }
            catch (Exception)
            {
                _proxyManager.Abort(proxy);
                throw;
            }
        }
Exemplo n.º 12
0
        void IEmailClient.Send(MailMessage message)
        {
            var service = _serviceManager.Create();

            try
            {
                service.Send(new MockEmail(message));
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);
        }
Exemplo n.º 13
0
        private void PostJobs(string method, List <Job> posts)
        {
            #region Log
            Logger.Raise(Event.Information, method, string.Format("Posting {0} job ads...", posts.Count));
            #endregion

            var request = new JobCollection {
                companyid = RemoteCompanyId, jobs = posts.ToArray()
            };
            var serializer = new XmlSerializer(typeof(JobCollection));
            var writer     = new StringWriter();
            serializer.Serialize(writer, request);
            writer.Flush();
            var    requestXml = writer.ToString();
            string response;

            // Send request.

            var service = _serviceManager.Create();
            try
            {
                response = service.Sync(requestXml, RemoteUsername, RemotePassword);
            }
            catch (Exception ex)
            {
                _serviceManager.Abort(service);

                _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdExportPostEvent {
                    Success = false, IntegratorUserId = _integratorUser.Id, Failed = posts.Count, JobAds = posts.Count
                });

                #region Log
                Logger.Raise(Event.CriticalError, method, string.Format("Aborting Service. {0}", ex));
                #endregion

                throw;
            }
            _serviceManager.Close(service);

            _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdExportPostEvent {
                Success = true, IntegratorUserId = _integratorUser.Id, Posted = posts.Count, JobAds = posts.Count
            });

            #region Log
            Logger.Raise(Event.Information, method, string.Format("Processing complete. {0}", response));
            #endregion
        }
        public override void ExecuteTask(string[] args)
        {
            var candidateId = new Guid(args[0]);

            var service = _serviceFactory.Create();

            try
            {
                service.LogWorkflow(candidateId);
                _serviceFactory.Close(service);
            }
            catch (Exception)
            {
                _serviceFactory.Abort(service);
                throw;
            }
        }
Exemplo n.º 15
0
        private void Update(Guid memberId)
        {
            // Update all search engines.

            _memberSearchEngineCommand.SetModified(memberId);

            // Make sure the local one is updated now.

            var service = _serviceManager.Create();

            try
            {
                service.UpdateMember(memberId);
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);
        }
Exemplo n.º 16
0
        private void UpdateJobAd(Guid jobAdId)
        {
            // The pattern would say that _jobAdSortEngineCommand.SetModified(jobAdId) would go here
            // but going to assume that the JobAdSearchSubscriber is going to make that call
            // which will trigger the updates of the job ad sort engines.

            // Make sure the local one is updated now.

            var service = _serviceManager.Create();

            try
            {
                service.UpdateJobAd(jobAdId);
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Execute a search on the Lucene resource index
        /// </summary>
        /// <param name="criteria">The criteria the search results need to meet</param>
        /// <param name="range">The number of results to return. Null means include all resources</param>
        /// <returns>A list of resourceItemIds meeting the criteria</returns>
        ResourceSearchExecution IExecuteResourceSearchCommand.Search(ResourceSearchCriteria criteria, Range range)
        {
            ResourceSearchResults results;
            var service = _serviceManager.Create();

            try
            {
                results = service.Search(criteria.GetSearchQuery(range), true);
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);

            return(new ResourceSearchExecution
            {
                Criteria = criteria,
                Results = results,
            });
        }
Exemplo n.º 18
0
        private void ExecuteTask(int?count, int?slowdownMilliseconds)
        {
            const string method = "ExecuteTask";

            IEnumerable <Tuple <Guid, CandidateStatus> > candidates = _candidatesWorkflowQuery.GetCandidatesWithoutStatusWorkflow();

            if (count.HasValue && count.Value != 0)
            {
                candidates = candidates.Take(count.Value);
            }

            Logger.Raise(Event.Information, method, string.Format("Creating CandidateStatus workflows for {0} candidates...", candidates.Count()));

            var workflowProxy = _workflowProxyFactory.Create();

            try
            {
                foreach (var candidate in candidates)
                {
                    workflowProxy.CreateWorkflow(candidate.Item1, candidate.Item2);

                    // Wait a little to avoid a burst in workflow activities.

                    if (slowdownMilliseconds.HasValue && slowdownMilliseconds.Value != 0)
                    {
                        Thread.Sleep(slowdownMilliseconds.Value);
                    }
                }

                _workflowProxyFactory.Close(workflowProxy);
            }
            catch (Exception)
            {
                _workflowProxyFactory.Abort(workflowProxy);
                throw;
            }
        }
        public void OnFrequencyChanged(object sender, CategoryFrequencyEventArgs e)
        {
            // Skip unrelated events.

            if (e.CategoryId != _categoryId)
            {
                return;
            }

            // Notify the workflow on frequency change.

            var proxy = _proxyManager.Create();

            try
            {
                proxy.OnFrequencyChanged(e.UserId, e.Frequency.ToTimeSpan());
                _proxyManager.Close(proxy);
            }
            catch (Exception)
            {
                _proxyManager.Abort(proxy);
                throw;
            }
        }
Exemplo n.º 20
0
        private void Add(JobAd jobAd)
        {
            const string method = "Add";

            var request = new AddVacancyRequestMessage {
                Body = _mapper.CreateAddRequestBody(jobAd)
            };

            SetSecurity(request);

            if (request.Body.daysToExpiry <= 2)
            {
                #region Log
                Logger.Raise(Event.Flow, method, "Job ad will not be published as it is about to expire.",
                             Event.Arg("jobAdId", jobAd.Id), Event.Arg("daysToExpiry", request.Body.daysToExpiry));
                #endregion

                return;
            }

            var channel = _channelManager.Create();
            AddVacancyResponseMessage response;
            try
            {
                response = channel.AddVacancy(request);
            }
            catch (Exception)
            {
                _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdExportPostEvent {
                    Success = false, IntegratorUserId = _integratorUser.Id, Failed = 1, JobAds = 1
                });
                _channelManager.Abort(channel);
                throw;
            }
            _channelManager.Close(channel);

            if (response.Header.executionStatus == EsiExecutionStatus.Failed)
            {
                var ser           = new System.Xml.Serialization.XmlSerializer(request.GetType());
                var requestStream = new StringWriter();
                ser.Serialize(requestStream, request);

                _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdExportPostEvent {
                    Success = false, IntegratorUserId = _integratorUser.Id, Failed = 1, JobAds = 1
                });

                #region Log
                Logger.Raise(Event.Error, method, response.Body.ErrorString,
                             Event.Arg("jobAdId", jobAd.Id),
                             Event.Arg("messages", Array.ConvertAll(response.Header.Messages, m => m.text)),
                             Event.Arg("request", requestStream));
                #endregion
                return;
            }

            _exportCommand.CreateJobSearchId(jobAd.Id, response.Body.vacancyID);

            _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdExportPostEvent {
                Success = true, IntegratorUserId = _integratorUser.Id, Posted = 1, JobAds = 1
            });

            #region Log
            Logger.Raise(Event.Flow, method, "Job ad has been published.", Event.Arg("jobAdId", jobAd.Id));
            #endregion
        }