Exemple #1
0
        private void Update(long vacancyId, JobAd jobAd)
        {
            const string method = "Update";

            // Update.

            var channel = _channelManager.Create();

            var request = new UpdateVacancyRequestMessage {
                Body = _mapper.CreateUpdateRequestBody(jobAd)
            };

            request.Body.vacancyID = vacancyId;

            var controlNumbers = GetControlNumbers(channel, vacancyId);

            request.Body.integrityControlNumber               = controlNumbers.integrityControlNumber;
            request.Body.contactIntegrityControlNumber        = controlNumbers.contactIntegrityControlNumber;
            request.Body.contactAddressIntegrityControlNumber = controlNumbers.contactAddressIntegrityControlNumber;
            request.Body.detailsIntegrityControlNumber        = controlNumbers.detailsIntegrityControlNumber;
            request.Body.agentIntegrityControlNumber          = controlNumbers.agentIntegrityControlNumber;

            SetSecurity(request);

            UpdateVacancyResponseMessage response;

            try
            {
                response = channel.UpdateVacancy(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)
            {
                _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)));

                #endregion
            }

            _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdExportPostEvent {
                Success = true, IntegratorUserId = _integratorUser.Id, Updated = 1, JobAds = 1
            });
        }
Exemple #2
0
 private void SetSecurity(UpdateVacancyRequestMessage request)
 {
     request.Security = new Security {
         UsernameToken = _usernameToken
     };
     request.Body.orgCode    = OrgCode;
     request.Body.siteCode   = SiteCode;
     request.Body.employerID = EmployerId;
 }