Skip to content

Commit

Permalink
refactor: rename extended service method to better reflect its intent
Browse files Browse the repository at this point in the history
  • Loading branch information
iainlomax81 committed Oct 23, 2024
1 parent 19d33f0 commit a009f34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,18 +316,18 @@ public TResponse Execute<TResponse>(OrganizationRequest request, string username
}

/// <inheritdoc/>
public bool HasStartedSolutionHistoryRecords(ILogger logger)
public void WaitForSolutionHistoryRecordsToComplete(ILogger logger)
{
var retryPolicy = Policy
.HandleResult<bool>(hasActiveRecords => !hasActiveRecords)
.HandleResult<bool>(hasActiveRecords => hasActiveRecords)
.WaitAndRetryForever(
sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(20),
onRetry: (result, timeSpan) =>
{
logger.LogInformation($"Active records still present within Solution History. Waiting for {timeSpan.TotalSeconds} seconds before retrying...");
logger.LogInformation($"Active records are still present within Solution History. Waiting for {timeSpan.TotalSeconds} seconds before retrying.");
});

var result = retryPolicy.Execute(() =>
retryPolicy.Execute(() =>
{
var entityCollection = this.crmSvc.RetrieveMultiple(new QueryByAttribute()
{
Expand All @@ -347,8 +347,6 @@ public bool HasStartedSolutionHistoryRecords(ILogger logger)
});
return entityCollection.TotalRecordCount > 0;
});

return result;
}

/// <inheritdoc/>
Expand All @@ -362,7 +360,7 @@ public ExecuteMultipleResponse ExecuteMultipleSolutionHistoryOperation(IEnumerab
sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(10),
onRetry: (ex, timeSpan) =>
{
this.HasStartedSolutionHistoryRecords(logger);
this.WaitForSolutionHistoryRecordsToComplete(logger);
});

retryPolicy.Execute(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,10 @@ public TResponse Execute<TResponse>(OrganizationRequest request, string username
string GetEntityTypeCode(string entityLogicalName);

/// <summary>
/// Checks whether there are any Solution History records in a <b>Started</b> state.
/// Waits for Solution History records in a <b>Started</b> state to complete.
/// </summary>
/// <param name="logger">Instane of ILogger.</param>
/// <returns>Returns <c>true</c> if active records are present in the Solution History; otherwise, returns <c>false</c>.</returns>
bool HasStartedSolutionHistoryRecords(ILogger logger);
void WaitForSolutionHistoryRecordsToComplete(ILogger logger);

/// <summary>
/// Executes multiple requests and performs a check on the Solution History during the operation.
Expand Down

0 comments on commit a009f34

Please sign in to comment.