public ActionResult JobAds() { const string method = "JobAds"; IntegratorUser user = null; try { // Authenticate. user = _serviceAuthenticationManager.AuthenticateRequest(HttpContext, IntegratorPermissions.PostJobAds); // Load the request. var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(GetRequestXml()); var xmlNsMgr = new XmlNamespaceManager(xmlDoc.NameTable); xmlNsMgr.AddNamespace(XmlNamespacePrefix, XmlNamespace); var xmlNode = xmlDoc.SelectSingleNode("/" + XmlNamespacePrefix + ":PostJobAdsRequest", xmlNsMgr); // Extract values. var jobPoster = GetJobPoster(xmlNode, xmlNsMgr); var integratorJobPoster = jobPoster == null ? _externalJobAdsQuery.GetJobPoster(user) : null; var closeAllOtherJobAds = jobPoster != null && GetCloseAllOtherAds(xmlNode, xmlNsMgr); var jobAds = GetJobAds(xmlNode, xmlNsMgr, jobPoster == null ? JobAdStatus.Draft : (JobAdStatus?)null); // Process. var report = _jobAdPostsManager.PostJobAds(user, jobPoster, integratorJobPoster, jobAds.Where(j => j != null), closeAllOtherJobAds); // Record it, including read failures. report.Failed += jobAds.Count(j => j == null); _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdImportPostEvent { Success = true, IntegratorUserId = user.Id, PosterId = (jobPoster ?? integratorJobPoster).Id, JobAds = jobAds.Count(j => j != null), Closed = report.Closed, Failed = report.Failed, Posted = report.Posted, Updated = report.Updated }); return(Xml(new PostJobAdsResponse(GetResponseXml(report), report.Errors.ToArray()))); } catch (Exception ex) { EventSource.Raise(ex.Message.EndsWith("disabled.") ? (Event)Event.NonCriticalError : Event.Error, method, "Cannot process the request.", ex, new StandardErrorHandler()); if (user != null) { _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdImportPostEvent { Success = false, IntegratorUserId = user.Id }); } return(Xml(new PostJobAdsResponse(ex))); } }
private void ExecuteTaskFiles(IList <string> files) { var reader = new JobFeedReader(RemoteBaseUrl, RemoteUsername, RemotePassword, files, Logger); var mapper = new JobAdMapper(_locationQuery, _industriesQuery, IgnoredCompanies); var integratorUser = _careerOneQuery.GetIntegratorUser(); var jobPoster = _externalJobAdsQuery.GetJobPoster(integratorUser); ProcessJobFeed(reader, mapper, integratorUser, jobPoster); }
private void ExecuteTaskCore(string filename) { var reader = new JobFeedReader(RemoteBaseUrl, filename, Logger); var mapper = new JobAdMapper(_locationQuery, _industriesQuery, IgnoredCompanies); var integratorUser = _jxtQuery.GetIntegratorUser(); var jobPoster = _externalJobAdsQuery.GetJobPoster(integratorUser); ProcessJobFeed(reader, mapper, integratorUser, jobPoster); }
public override void ExecuteTask() { if (string.IsNullOrEmpty(IntegratorUserLoginId)) { throw new ApplicationException("The IntegratorUserLoginId is not set."); } if (string.IsNullOrEmpty(JobPosterLoginId)) { throw new ApplicationException("The JobPosterLoginId is not set."); } if (string.IsNullOrEmpty(RemoteUrl)) { throw new ApplicationException("The RemoteUrl is not set."); } var reader = new JobFeedReader(RemoteUrl); var mapper = new JobFeedMapper(_industriesQuery, _locationQuery); var integratorUser = _integrationQuery.GetIntegratorUser(IntegratorUserLoginId); if (integratorUser == null) { throw new ApplicationException("The integrator user with login id '" + IntegratorUserLoginId + "' cannot be found."); } var jobPoster = _externalJobAdsQuery.GetJobPoster(integratorUser, JobPosterLoginId); if (jobPoster == null) { throw new ApplicationException("The job poster with login id '" + JobPosterLoginId + "' cannot be found."); } ProcessJobFeed(reader, mapper, integratorUser, jobPoster); }