private async Task UpdateCriticalSectionStateAsync(int taskDefinitionId, CriticalSectionState csState, CriticalSectionType criticalSectionType, SqlCommand command)
{
command.Parameters.Clear();
if (criticalSectionType == CriticalSectionType.User)
{
command.CommandText = TokensQueryBuilder.SetUserCriticalSectionStateQuery;
}
else
{
command.CommandText = TokensQueryBuilder.SetClientCriticalSectionStateQuery;
}
command.Parameters.Add("@TaskDefinitionId", SqlDbType.Int).Value = taskDefinitionId;
command.Parameters.Add("@CsStatus", SqlDbType.Int).Value = csState.IsGranted ? 1 : 0;
command.Parameters.Add("@CsTaskExecutionId", SqlDbType.Int).Value = csState.GrantedToExecution;
command.Parameters.Add("@CsQueue", SqlDbType.VarChar, 8000).Value = csState.GetQueueString();
await command.ExecuteNonQueryAsync().ConfigureAwait(false);
}