public void BracketCodeContentIdsFindsAllMatchesInBackToBackBracketCodes()
        {
            var testString = @"
A Test Post for Ironwood Forest National Monument. From
Wikipedia:
> Ironwood Forest National Monument is located in the Sonoran Desert of Arizona. Created by Bill Clinton by Presidential Proclamation 7320 on June 9, 2000, the monument is managed by the Bureau of Land Management, an agency within the United States Department of the Interior. The monument covers 129,055 acres (52,227 ha),[2] of which 59,573 acres (24,108 ha) are non-federal and include private land holdings and Arizona State School Trust lands.

A significant concentration of ironwood (also known as desert ironwood, Olneya tesota) trees is found in the monument, along with two federally recognized endangered animal and plant species. More than 200 Hohokam and Paleo-Indian archaeological sites have been identified in the monument, dated between 600 and 1450.{{photo efe8caac-9d62-4456-af54-873c0d6a0dce; 2018 August Agua Blanca Ranch Sign at the Manville Road Entrance to the Ironwood Forest National Monument}}{{photo d1bc6caf-2155-45f8-ac35-6b811535de0d; 2020 June Disappearing into the Flower}}{{photo 11d4c9e7-bfa0-489d-8dc0-69e93e3384de; 2020 May A Quarry in Ironwood Forest National Monument}}{{photo 481f4177-329b-46ae-8f53-b9f742a3d227; 2020 May Ironwood Pod}}{{photo 8526996b-71b5-4d31-85a8-4267619884b5; 2017 May Ironwood Tree Against The Sky}}Basic information for Ironwood Forest National Monument
";
            var result     = BracketCodeCommon.BracketCodeContentIds(testString);

            Assert.AreEqual(5, result.Count);
        }
        public void BracketCodeContentIdsFindsAllMatches()
        {
            var testString = @"
A Test Post for Ironwood Forest National Monument. From
Wikipedia:
> Ironwood Forest National Monument is located in the Sonoran Desert of Arizona. Created by Bill Clinton by Presidential Proclamation 7320 on June 9, 2000, the monument is managed by the Bureau of Land Management, an agency within the United States Department of the Interior. The monument covers 129,055 acres (52,227 ha),[2] of which 59,573 acres (24,108 ha) are non-federal and include private land holdings and Arizona State School Trust lands.

A significant concentration of ironwood (also known as desert ironwood, Olneya tesota) trees is found in the monument, along with two federally recognized endangered animal and plant species. More than 200 Hohokam and Paleo-Indian archaeological sites have been identified in the monument, dated between 600 and 1450.

{{photo be010d97-a2b1-4c88-97ac-c36ebbd3fad4; 2020 June Disappearing into the Flower}}
{{photo ce493d74-516c-4e7d-a51f-2db458a834e3; 2020 May Ironwood Pod}}
{{photo 32563d87-d002-4672-a27e-d0b31c2a6875; 2020 May A Quarry in Ironwood Forest National Monument}}
{{photo d45ef8f8-e376-4144-acef-164310ee85bc; 2017 May Ironwood Tree Against The Sky}}
{{photo 611a88cd-908b-45bc-ac3c-a904b0c7a9c7; 2018 August Agua Blanca Ranch Sign at the Manville Road Entrance to the Ironwood Forest National Monument}}Basic information for Ironwood Forest National Monument
";
            var result     = BracketCodeCommon.BracketCodeContentIds(testString);

            Assert.AreEqual(5, result.Count);
        }
Beispiel #3
0
        public static async Task ExtractAndWriteRelatedContentDbReferencesFromString(Guid sourceGuid, string toSearch,
                                                                                     PointlessWaymarksContext db, IProgress <string> progress)
        {
            if (string.IsNullOrWhiteSpace(toSearch))
            {
                return;
            }

            var toAdd = BracketCodeCommon.BracketCodeContentIds(toSearch);

            if (!toAdd.Any())
            {
                return;
            }

            var dbEntries = toAdd.Select(x => new GenerationRelatedContent {
                ContentOne = sourceGuid, ContentTwo = x
            });

            await db.GenerationRelatedContents.AddRangeAsync(dbEntries);
        }
Beispiel #4
0
        public static async Task ExtractAndWriteRelatedContentDbReferences(DateTime generationVersion,
                                                                           IContentCommon content, PointlessWaymarksContext db, IProgress <string> progress)
        {
            var toAdd = new List <Guid>();

            if (content.MainPicture != null && content.MainPicture != content.ContentId)
            {
                toAdd.Add(content.MainPicture.Value);
            }

            var toSearch = string.Empty;

            toSearch += content.BodyContent + content.Summary;

            if (content is IUpdateNotes updateContent)
            {
                toSearch += updateContent.UpdateNotes;
            }

            if (string.IsNullOrWhiteSpace(toSearch) && !toAdd.Any())
            {
                return;
            }

            toAdd.AddRange(BracketCodeCommon.BracketCodeContentIds(toSearch));

            if (!toAdd.Any())
            {
                return;
            }

            var dbEntries = toAdd.Distinct().Select(x => new GenerationRelatedContent
            {
                ContentOne = content.ContentId, ContentTwo = x, GenerationVersion = generationVersion
            });

            await db.GenerationRelatedContents.AddRangeAsync(dbEntries);

            await db.SaveChangesAsync();
        }
Beispiel #5
0
        public static async Task <GenerationReturn> CheckStringForBadContentReferences(string toSearch,
                                                                                       PointlessWaymarksContext db, IProgress <string> progress)
        {
            var extracted = new List <Guid>();

            if (string.IsNullOrWhiteSpace(toSearch))
            {
                return(await GenerationReturn.Success("No Content Ids Found"));
            }

            extracted.AddRange(BracketCodeCommon.BracketCodeContentIds(toSearch));

            if (!extracted.Any())
            {
                return(await GenerationReturn.Success("No Content Ids Found"));
            }

            progress?.Report($"Found {extracted.Count} ContentIds to check for");

            var notFoundList = new List <Guid>();

            foreach (var loopExtracted in extracted)
            {
                var contentLookup = await db.ContentFromContentId(loopExtracted);

                if (contentLookup == null)
                {
                    progress?.Report($"ContentId {loopExtracted} Not Found in Db...");
                    notFoundList.Add(loopExtracted);
                }
            }

            if (notFoundList.Any())
            {
                return(await GenerationReturn.Error(
                           $"Invalid ContentIds in Bracket Codes - {string.Join(", ", notFoundList)}"));
            }

            return(await GenerationReturn.Success("No Invalid Content Ids Found"));
        }
Beispiel #6
0
        public static async Task <GenerationReturn> CheckForBadContentReferences(IContentCommon content,
                                                                                 PointlessWaymarksContext db, IProgress <string> progress)
        {
            progress?.Report($"Checking ContentIds for {content.Title}");

            var extracted = new List <Guid>();

            if (content.MainPicture != null && content.MainPicture != content.ContentId)
            {
                extracted.Add(content.MainPicture.Value);
            }

            var toSearch = string.Empty;

            toSearch += content.BodyContent + content.Summary;

            if (content is IUpdateNotes updateContent)
            {
                toSearch += updateContent.UpdateNotes;
            }

            if (content is PointContentDto pointDto)
            {
                pointDto.PointDetails.ForEach(x => toSearch += x.StructuredDataAsJson);
            }

            if (content is PointContent point)
            {
                (await Db.PointDetailsForPoint(point.ContentId, db)).ForEach(x => toSearch += x.StructuredDataAsJson);
            }

            if (string.IsNullOrWhiteSpace(toSearch) && !extracted.Any())
            {
                return(await GenerationReturn.Success(
                           $"{Db.ContentTypeString(content)} {content.Title} - No Content Ids Found", content.ContentId));
            }

            extracted.AddRange(BracketCodeCommon.BracketCodeContentIds(toSearch));

            if (!extracted.Any())
            {
                return(await GenerationReturn.Success(
                           $"{Db.ContentTypeString(content)} {content.Title} - No Content Ids Found", content.ContentId));
            }

            progress?.Report($"Found {extracted.Count} ContentIds to check for {content.Title}");

            var notFoundList = new List <Guid>();

            foreach (var loopExtracted in extracted)
            {
                var contentLookup = await db.ContentFromContentId(loopExtracted);

                if (contentLookup != null)
                {
                    continue;
                }
                if (await db.MapComponents.AnyAsync(x => x.ContentId == loopExtracted))
                {
                    continue;
                }

                progress?.Report($"ContentId {loopExtracted} Not Found in Db...");
                notFoundList.Add(loopExtracted);
            }

            if (notFoundList.Any())
            {
                return(await GenerationReturn.Error(
                           $"{Db.ContentTypeString(content)} {content.Title} has " +
                           $"Invalid ContentIds in Bracket Codes - {string.Join(", ", notFoundList)}", content.ContentId));
            }

            return(await GenerationReturn.Success(
                       $"{Db.ContentTypeString(content)} {content.Title} - No Invalid Content Ids Found"));
        }