string GetPrimaryFilterExpression(OrchestrationStateQueryFilter filter, bool isJumpStartTable) { string basicPrimaryFilter; if (!isJumpStartTable) { basicPrimaryFilter = string.Format(CultureInfo.InvariantCulture, AzureTableConstants.PrimaryFilterTemplate); } else { basicPrimaryFilter = string.Format( CultureInfo.InvariantCulture, AzureTableConstants.PrimaryTimeRangeTemplate, AzureTableOrchestrationJumpStartEntity.GetPartitionKey(DateTime.UtcNow.AddDays(-1)), AzureTableOrchestrationJumpStartEntity.GetPartitionKey(DateTime.UtcNow)); } string filterExpression = string.Empty; if (filter != null) { if (filter is OrchestrationStateInstanceFilter) { var typedFilter = filter as OrchestrationStateInstanceFilter; if (typedFilter.StartsWith) { filterExpression = string.Format(CultureInfo.InvariantCulture, AzureTableConstants.PrimaryInstanceQueryRangeTemplate, typedFilter.InstanceId, ComputeNextKeyInRange(typedFilter.InstanceId)); } else { if (string.IsNullOrEmpty(typedFilter.ExecutionId)) { filterExpression = string.Format(CultureInfo.InvariantCulture, AzureTableConstants.PrimaryInstanceQueryRangeTemplate, typedFilter.InstanceId, ComputeNextKeyInRange(typedFilter.InstanceId)); } else { filterExpression = string.Format(CultureInfo.InvariantCulture, AzureTableConstants.PrimaryInstanceQueryExactTemplate, typedFilter.InstanceId, typedFilter.ExecutionId); } } } else { // TODO : for now we don't have indexes for anything other than the // instance id so all filters are 'secondary' filters filterExpression = GetSecondaryFilterExpression(filter); } } return(basicPrimaryFilter + (string.IsNullOrEmpty(filterExpression) ? string.Empty : " and " + filterExpression)); }
internal override IEnumerable <ITableEntity> BuildDenormalizedEntities() { var entity1 = new AzureTableOrchestrationJumpStartEntity(OrchestrationJumpStartInstanceEntity); entity1.TaskTimeStamp = TaskTimeStamp; entity1.PartitionKey = GetPartitionKey(entity1.State.CreatedTime); entity1.RowKey = AzureTableConstants.InstanceStateExactRowPrefix + AzureTableConstants.JoinDelimiter + State.OrchestrationInstance.InstanceId + AzureTableConstants.JoinDelimiter + State.OrchestrationInstance.ExecutionId; return(new [] { entity1 }); }
TableQuery <AzureTableOrchestrationJumpStartEntity> CreateJumpStartQuery(DateTime startTime, DateTime endTime, int count) { string filterExpression = string.Format( CultureInfo.InvariantCulture, AzureTableConstants.PrimaryTimeRangeTemplate, AzureTableOrchestrationJumpStartEntity.GetPartitionKey(startTime), AzureTableOrchestrationJumpStartEntity.GetPartitionKey(endTime)); TableQuery <AzureTableOrchestrationJumpStartEntity> query = new TableQuery <AzureTableOrchestrationJumpStartEntity>().Where(filterExpression); if (count != -1) { query.TakeCount = count; } return(query); }