private static SetInfo CreateSetInfoFromEntity(CloudTableClient client, SetEntity set) { SetInfo setInfo = new SetInfo(); setInfo.CompletedAt = set.CompletedOn; setInfo.CompletedWorkItems = new List <WorkItem>(); setInfo.Container = set.ResultContainer; setInfo.ExpectedWorkItems = set.TextureTilesX * set.TextureTilesY; setInfo.Id = set.RowKey; setInfo.InProgressWorkItems = new List <WorkItem>(); setInfo.Path = set.ResultPath; setInfo.QueuedAt = set.CreatedOn; setInfo.Status = "NotStarted"; TableQuery <WorkEntity> workQuery = new TableQuery <WorkEntity>().Where( TableQuery.GenerateFilterCondition( "PartitionKey", QueryComparisons.Equal, WorkEntity.EncodeResultPath(set.ResultPath, set.ResultContainer)) ); IEnumerable <WorkEntity> workEntities = client.GetTableReference(WorkTableName).ExecuteQuery(workQuery); foreach (var workEntity in workEntities) { WorkItem workItem = new WorkItem(); workItem.X = workEntity.TextureTileX; workItem.Y = workEntity.TextureTileY; workItem.StartedAt = workEntity.StartTime; workItem.CompletedAt = workEntity.CompletedTime; if (workItem.CompletedAt.HasValue) { setInfo.CompletedWorkItems.Add(workItem); } else { setInfo.Status = "InProgress"; setInfo.InProgressWorkItems.Add(workItem); } } if (set.Completed) { setInfo.Status = "Completed"; } else if (set.Failed) { setInfo.Status = "Failed"; } return(setInfo); }
public static int GetWorkCompletedCount(CloudTableClient client, string resultPath, string container) { var workTable = client.GetTableReference(WorkTableName); TableQuery <WorkEntity> workItemQuery = new TableQuery <WorkEntity>().Where( TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, WorkEntity.EncodeResultPath(resultPath, container)), TableOperators.And, TableQuery.GenerateFilterCondition("CompletedTime", QueryComparisons.NotEqual, ""))).Select(new[] { "RowKey" }); var completedItems = workTable.ExecuteQuery(workItemQuery); return(completedItems.ToList().Count); }
public static IEnumerable <WorkEntity> GetWorkCompletedMetadata(CloudTableClient client, string resultPath, string container) { var workTable = client.GetTableReference(WorkTableName); TableQuery <WorkEntity> workItemQuery = new TableQuery <WorkEntity>().Where( TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, WorkEntity.EncodeResultPath(resultPath, container)), TableOperators.And, TableQuery.GenerateFilterCondition("CompletedTime", QueryComparisons.NotEqual, ""))); return(workTable.ExecuteQuery(workItemQuery)); }