public GetCancelJobUri ( System.Guid jobId ) : |
||
jobId | System.Guid | |
Результат |
public void ShouldReturnCorrectCancelJobUri() { NodeUriBuilderHelperToTest = new NodeUriBuilderHelper(UriToTest); Assert.IsTrue(NodeUriBuilderHelperToTest.GetCancelJobUri(Guid) == CancelJobUri); }
private void CancelJobByJobIdWorker(Guid jobId) { try { using (var sqlConnection = new SqlConnection(_connectionString)) { sqlConnection.OpenWithRetry(_retryPolicy); using (var sqlTransaction = sqlConnection.BeginTransaction()) { string sentToWorkerNodeUri = null; using (var createSelectWorkerNodeUriCommand = _createSqlCommandHelper.CreateSelectWorkerNodeCommand(jobId, sqlConnection, sqlTransaction)) { using (var selectSqlReader = createSelectWorkerNodeUriCommand.ExecuteReaderWithRetry(_retryPolicy)) { if (selectSqlReader.HasRows) { selectSqlReader.Read(); sentToWorkerNodeUri = selectSqlReader.GetString(selectSqlReader.GetOrdinal("SentToWorkerNodeUri")); } } } if (sentToWorkerNodeUri != null) { var builderHelper = new NodeUriBuilderHelper(sentToWorkerNodeUri); var uriCancel = builderHelper.GetCancelJobUri(jobId); var response = _httpSender.DeleteAsync(uriCancel).Result; if (response != null && response.IsSuccessStatusCode) { using (var createUpdateCancellingResultCommand = _createSqlCommandHelper.CreateUpdateCancellingResultCommand(jobId, sqlConnection, sqlTransaction)) { createUpdateCancellingResultCommand.ExecuteNonQueryWithRetry(_retryPolicy); } using (var deleteFromJobDefinitionsCommand = _createSqlCommandHelper.CreateDeleteFromJobQueueCommand(jobId, sqlConnection, sqlTransaction)) { deleteFromJobDefinitionsCommand.ExecuteNonQueryWithRetry(_retryPolicy); } Retry(sqlTransaction.Commit); } else { this.Log().ErrorWithLineNumber("Could not send cancel to node. JobId: " + jobId); } } } } } catch (Exception exp) { this.Log().ErrorWithLineNumber(exp.Message, exp); throw; } }