Пример #1
0
        public static string ProcessCodesForEmail(string input, IProgress <string> progress)
        {
            input = BracketCodeFileDownloads.Process(input, progress);
            input = BracketCodeFiles.Process(input, progress);
            input = BracketCodeGeoJsonLinks.Process(input, progress);
            input = BracketCodeImages.ProcessForEmail(input, progress);
            input = BracketCodeImageLinks.Process(input, progress);
            input = BracketCodeLineLinks.Process(input, progress);
            input = BracketCodeNotes.Process(input, progress);
            input = BracketCodePhotos.ProcessForEmail(input, progress);
            input = BracketCodePhotoLinks.Process(input, progress);
            input = BracketCodePosts.Process(input, progress);
            input = BracketCodePointLinks.Process(input, progress);
            input = BracketCodeSpecialPages.Process(input, progress);

            return(input);
        }
Пример #2
0
        public static string ProcessCodesForSite(string input, IProgress <string> progress)
        {
            input = BracketCodeFileDownloads.Process(input, progress);
            input = BracketCodeFiles.Process(input, progress);
            input = BracketCodeGeoJson.Process(input, progress);
            input = BracketCodeGeoJsonLinks.Process(input, progress);
            input = BracketCodeImages.ProcessToFigureWithLink(input, progress);
            input = BracketCodeImageLinks.Process(input, progress);
            input = BracketCodeLines.Process(input, progress);
            input = BracketCodeLineLinks.Process(input, progress);
            input = BracketCodeMapComponents.Process(input, progress);
            input = BracketCodeNotes.Process(input, progress);
            input = BracketCodePhotos.ProcessToFigureWithLink(input, progress);
            input = BracketCodePhotoLinks.Process(input, progress);
            input = BracketCodePoints.Process(input, progress);
            input = BracketCodePointLinks.Process(input, progress);
            input = BracketCodePosts.Process(input, progress);
            input = BracketCodeSpecialPages.Process(input, progress);

            return(input);
        }
        public static async Task <HtmlTag> RelatedContentTag(Guid toCheckFor, string bodyContentToCheckIn,
                                                             DateTime?generationVersion, IProgress <string> progress = null)
        {
            var contentCommonList = new List <IContentCommon>();

            var db = await Db.Context();

            contentCommonList.AddRange(
                await RelatedContentReferencesFromOtherContent(db, toCheckFor, generationVersion));
            contentCommonList.AddRange(BracketCodeFiles.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(
                BracketCodeFileDownloads.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(BracketCodeGeoJson.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(
                BracketCodeGeoJsonLinks.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(BracketCodeImages.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(BracketCodeImageLinks.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(BracketCodeLines.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(BracketCodeLineLinks.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(BracketCodeNotes.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(BracketCodePoints.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(BracketCodePointLinks.DbContentFromBracketCodes(bodyContentToCheckIn, progress));
            contentCommonList.AddRange(BracketCodePosts.DbContentFromBracketCodes(bodyContentToCheckIn, progress));

            var transformedList = new List <(DateTime sortDateTime, HtmlTag tagContent)>();

            if (contentCommonList.Any())
            {
                contentCommonList = contentCommonList.GroupBy(x => x.ContentId).Select(x => x.First()).ToList();

                foreach (var loopContent in contentCommonList)
                {
                    var toAdd = RelatedContentDiv(loopContent);
                    if (toAdd != null && !toAdd.IsEmpty())
                    {
                        transformedList.Add((loopContent.LastUpdatedOn ?? loopContent.CreatedOn, toAdd));
                    }
                }
            }

            var photoContent = BracketCodePhotos.DbContentFromBracketCodes(bodyContentToCheckIn, progress);

            photoContent.AddRange(BracketCodePhotoLinks.DbContentFromBracketCodes(bodyContentToCheckIn, progress));

            //If the object itself is a photo add it to the list
            photoContent.AddIfNotNull(await db.PhotoContents.SingleOrDefaultAsync(x => x.ContentId == toCheckFor));

            if (photoContent.Any())
            {
                var dates = photoContent.Select(x => x.PhotoCreatedOn.Date).Distinct().ToList();

                foreach (var loopDates in dates)
                {
                    var toAdd = await DailyPhotoPageGenerators.DailyPhotoGallery(loopDates, null);

                    if (toAdd != null)
                    {
                        transformedList.Add((loopDates, DailyPhotosPageParts.DailyPhotosPageRelatedContentDiv(toAdd)));
                    }
                }
            }

            var relatedTags = transformedList.OrderByDescending(x => x.sortDateTime).Select(x => x.tagContent).ToList();

            if (!relatedTags.Any())
            {
                return(HtmlTag.Empty());
            }

            var relatedPostsList = new DivTag().AddClass("related-posts-list-container");

            relatedPostsList.Children.Add(new DivTag().Text("Related:").AddClass("related-post-label-tag"));

            foreach (var loopPost in relatedTags)
            {
                relatedPostsList.Children.Add(loopPost);
            }

            return(relatedPostsList);
        }