public void SetQueue(string queueStr)
{
_queue = new List<CriticalSectionQueueItem>();
if (!string.IsNullOrEmpty(queueStr))
{
var queueItems = queueStr.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var queueItem in queueItems)
{
var parts = queueItem.Split(',');
int index = int.Parse(parts[0]);
_queue.Add(new CriticalSectionQueueItem(index, parts[1]));
}
}
}
private async Task <CriticalSectionState> GetCriticalSectionStateAsync(int taskDefinitionId, CriticalSectionType criticalSectionType, SqlCommand command) { command.Parameters.Clear(); if (criticalSectionType == CriticalSectionType.User) { command.CommandText = TokensQueryBuilder.GetUserCriticalSectionStateQuery; } else { command.CommandText = TokensQueryBuilder.GetClientCriticalSectionStateQuery; } command.Parameters.Add("@TaskDefinitionId", SqlDbType.Int).Value = taskDefinitionId; using (var reader = await command.ExecuteReaderAsync().ConfigureAwait(false)) { var readSuccess = await reader.ReadAsync().ConfigureAwait(false); if (readSuccess) { var csState = new CriticalSectionState(); csState.IsGranted = int.Parse(reader[GetCsStatusColumnName(criticalSectionType)].ToString()) == 0; csState.GrantedToExecution = reader[GetGrantedToColumnName(criticalSectionType)].ToString(); csState.SetQueue(reader[GetQueueColumnName(criticalSectionType)].ToString()); csState.StartTrackingModifications(); return(csState); } } throw new CriticalSectionException("No Task exists with id " + taskDefinitionId); }