示例#1
0
        private void Delete(long vacancyId)
        {
            const string method = "Delete";

            var channel = _channelManager.Create();

            var request = new DeleteVacancyRequestMessage
            {
                Body = new DeleteVacancyRequestBody {
                    vacancyID = vacancyId
                }
            };

            var controlNumbers = GetControlNumbers(channel, vacancyId);

            request.Body.integrityControlNumber = controlNumbers.integrityControlNumber;

            SetSecurity(request);

            DeleteVacancyResponseMessage response;

            try
            {
                response = channel.DeleteVacancy(request);
            }
            catch (Exception)
            {
                _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdExportCloseEvent {
                    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 JobAdExportCloseEvent {
                    Success = false, IntegratorUserId = _integratorUser.Id, Failed = 1, JobAds = 1
                });

                #region Log

                Logger.Raise(Event.Error, method, "A call to the DeleteVacancy service failed.",
                             Event.Arg("vacancyId", vacancyId),
                             Event.Arg("messages", Array.ConvertAll(response.Header.Messages, m => m.text)));

                #endregion
            }

            _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdExportCloseEvent {
                Success = true, IntegratorUserId = _integratorUser.Id, Closed = 1, JobAds = 1
            });
        }
示例#2
0
 private void SetSecurity(DeleteVacancyRequestMessage request)
 {
     request.Security = new Security {
         UsernameToken = _usernameToken
     };
 }