public Task <IEnumerable <ReleaseStatus> > GetAllByOverallStage(Guid releaseId, params ReleaseStatusOverallStage[] overallStages)
        {
            var filter = TableQuery.GenerateFilterCondition(nameof(ReleaseStatus.PartitionKey),
                                                            QueryComparisons.Equal, releaseId.ToString());

            if (overallStages.Any())
            {
                var allStageFilters = overallStages.ToList().Aggregate("", (acc, stage) =>
                {
                    var stageFilter = TableQuery.GenerateFilterCondition(
                        nameof(ReleaseStatus.OverallStage),
                        QueryComparisons.Equal,
                        stage.ToString()
                        );

                    if (acc == "")
                    {
                        return(stageFilter);
                    }

                    return(TableQuery.CombineFilters(acc, TableOperators.Or, stageFilter));
                });

                filter = TableQuery.CombineFilters(filter, TableOperators.And, allStageFilters);
            }

            var query = new TableQuery <ReleaseStatus>().Where(filter);

            return(_publisherTableStorageService.ExecuteQueryAsync(PublisherReleaseStatusTableName, query));
        }
Esempio n. 2
0
        public async Task DeleteAllReleaseFastTracks()
        {
            var allPartitionKeys = (await _tableStorageService.ExecuteQueryAsync(PublicReleaseFastTrackTableName,
                                                                                 new TableQuery <ReleaseFastTrack>()))
                                   .Select(track => track.PartitionKey)
                                   .Distinct();

            await _tableStorageService.DeleteByPartitionKeys(PublicReleaseFastTrackTableName, allPartitionKeys);
        }
        public async Task <Either <ActionResult, List <ImportStatusBau> > > GetAllIncompleteImports()
        {
            return(await _userService
                   .CheckCanViewAllImports()
                   .OnSuccess(async() =>
            {
                var queryFilterCondition = TableQuery.GenerateFilterCondition("Status",
                                                                              QueryComparisons.NotEqual,
                                                                              IStatus.COMPLETE.ToString());
                var tableQuery = new TableQuery <DatafileImport>().Where(queryFilterCondition);
                var queryResults = await _tableStorageService.ExecuteQueryAsync(
                    DatafileImportsTableName, tableQuery);

                return queryResults
                .OrderByDescending(result => result.Timestamp)
                .Select(async result =>
                {
                    var releaseId = new Guid(result.PartitionKey);
                    var dataFileName = result.RowKey;

                    var releaseFileRef = await _contentDbContext.Files.Where(
                        r =>
                        r.ReleaseId == releaseId &&
                        r.Filename == dataFileName &&
                        r.Type == FileType.Data)
                                         .Include(f => f.Release)
                                         .ThenInclude(r => r.Publication)
                                         .FirstOrDefaultAsync();

                    if (releaseFileRef == null)
                    {
                        _logger.LogWarning(
                            "No ReleaseFileReference found! " +
                            $"releaseId: \"{releaseId}\" " +
                            $"dataFileName: \"{dataFileName}\"");
                        return null;
                    }

                    return new ImportStatusBau()
                    {
                        SubjectTitle = null,         // EES-1655
                        SubjectId = releaseFileRef.SubjectId,
                        PublicationId = releaseFileRef.Release.PublicationId,
                        PublicationTitle = releaseFileRef.Release.Publication.Title,
                        ReleaseId = releaseFileRef.Release.Id,
                        ReleaseTitle = releaseFileRef.Release.Title,
                        DataFileName = result.RowKey,
                        NumberOfRows = result.NumberOfRows,
                        Status = result.Status,
                        StagePercentageComplete = result.PercentageComplete,
                    };
                })
                .Select(t => t?.Result)
                .Where(item => item != null)
                .ToList();
            }));
        }
Esempio n. 4
0
        private async Task <IEnumerable <IdLabel> > GetHighlights(Guid releaseId)
        {
            var releaseFilter = TableQuery.GenerateFilterCondition(nameof(ReleaseFastTrack.PartitionKey),
                                                                   QueryComparisons.Equal, releaseId.ToString());

            var highlightFilter = TableQuery.GenerateFilterCondition(nameof(ReleaseFastTrack.HighlightName), QueryComparisons.NotEqual,
                                                                     string.Empty);

            var combineFilter = TableQuery.CombineFilters(releaseFilter, TableOperators.And, highlightFilter);
            var query         = new TableQuery <ReleaseFastTrack>().Where(combineFilter);

            return((await _tableStorageService.ExecuteQueryAsync(PublicReleaseFastTrackTableName, query))
                   .Select(releaseFastTrack => new IdLabel(releaseFastTrack.FastTrackId, releaseFastTrack.HighlightName)));
        }
        private async Task <Either <ActionResult, ReleaseFastTrack> > GetReleaseFastTrack(Guid id)
        {
            // Assume that ReleaseFastTrack has a unique row key across all partitions
            var query = new TableQuery <ReleaseFastTrack>()
                        .Where(TableQuery.GenerateFilterCondition(nameof(ReleaseFastTrack.RowKey),
                                                                  QueryComparisons.Equal, id.ToString()));

            var tableResult = await _tableStorageService.ExecuteQueryAsync(PublicReleaseFastTrackTableName, query);

            var entity = tableResult.FirstOrDefault();

            return(entity == null
                ? new NotFoundResult()
                : new Either <ActionResult, ReleaseFastTrack>(entity));
        }
Esempio n. 6
0
        public async Task <Either <ActionResult, ReleaseStatusViewModel> > GetReleaseStatusAsync(Guid releaseId)
        {
            return(await _persistenceHelper
                   .CheckEntityExists <Release>(releaseId)
                   .OnSuccess(_userService.CheckCanViewRelease)
                   .OnSuccess(async _ =>
            {
                var query = new TableQuery <ReleaseStatus>()
                            .Where(TableQuery.GenerateFilterCondition(nameof(ReleaseStatus.PartitionKey),
                                                                      QueryComparisons.Equal, releaseId.ToString()));

                var result = await _publisherTableStorageService.ExecuteQueryAsync(PublisherReleaseStatusTableName, query);
                var first = result.OrderByDescending(releaseStatus => releaseStatus.Created).FirstOrDefault();
                return _mapper.Map <ReleaseStatusViewModel>(first);
            }));
        }
Esempio n. 7
0
 private Task <IEnumerable <ReleaseStatus> > ExecuteQueryAsync(TableQuery <ReleaseStatus> query)
 {
     return(_tableStorageService.ExecuteQueryAsync(PublisherReleaseStatusTableName, query));
 }