Exemplo n.º 1
0
        /// <summary>
        /// Get new and updated documents
        /// </summary>
        private async Task <List <SpotlightItem> > GetNewAndUpdated()
        {
            var mobileAppConfigurationId = await _settingsDataService.GetCurrentMobileConfigurationID();

            var categoriesInfo = await _categoryInfoDataService.GetCategoryInfos();

            var newCategoryContents = await _newCategoryContentDataService.GetCategoryContent(mobileAppConfigurationId);

            var newCategoriesInfo = categoriesInfo.Where(ci => newCategoryContents.Any(cc => cc.CategoryId == ci.Category.Id));

            var lastSyncID = await _syncDataService.GetSyncConfig(SuccessfulSyncState.SyncedObjectMetaType.ContentDocuments.ToString());

            var documentsSyncInfo = await _syncDataService.GetSyncConfigs(lastSyncID?.SyncId);

            var contentDistributions = await _contentDistributionDataService.GetAllContentDistributions();

            var contentDocuments = await _contentDocumentDataService.GetContentDocumentsByID(documentsSyncInfo.Select(si => si.TransactionItemType).Union(newCategoryContents.Select(ncc => ncc.ContentId)));

            var allDocumentsSyncInfo = await _syncDataService.GetSyncConfigs(contentDocuments.Select(cd => cd.Id));

            var documentsWithSyncVersion = allDocumentsSyncInfo.Join(contentDocuments, si => si.TransactionItemType, cd => cd.Id, (si, cd) => new { Document = cd, Sync = si });
            var documentsInfos           = documentsWithSyncVersion.Select(dsc => new DocumentInfo(dsc.Document, dsc.Sync, contentDistributions.FirstOrDefault(cd => cd.ContentVersionId == dsc.Document.LatestPublishedVersionId)));

            return(documentsInfos.Select(fd =>
            {
                var categoryInfo = newCategoriesInfo.FirstOrDefault(csi => csi.Documents.Any(d => d.Document.Id == fd.Document.Id));
                categoryInfo = categoryInfo ?? categoriesInfo.FirstOrDefault(csi => csi.Documents.Any(d => d.Document.Id == fd.Document.Id));
                return new SpotlightItem
                {
                    Name = fd.Document.Title,
                    Description = fd.Document.Description,
                    Location = categoryInfo != null ? GetLocation(categoryInfo, categoriesInfo) : string.Empty,
                    Media = new MediaLink(fd),
                    AddedOn = fd.Document.PublishedVersionLastModifiedDate,
                    Group = SpotlightGroup.NewAndUpdated,
                };
            }).OrderByDescending(d => d.AddedOn.GetValueOrDefault().DayOfYear).ThenBy(d => d.Name).ToList());
        }
Exemplo n.º 2
0
        public async Task <List <DocumentInfo> > GetContentDocumentsByID(IEnumerable <string> contentIDs)
        {
            var documents = await _contentDocumentDataService.GetContentDocumentsByID(contentIDs);

            return(await GetDocumentsInfo(documents));
        }