コード例 #1
0
        static void Main(string[] args)
        {
            ValidationResult result = APIValidator.Validate("https://api.porism.com/ServiceDirectoryServiceOpenActiveAggregated/", string.Empty).GetAwaiter().GetResult();

            Console.WriteLine(result.ToString());
            Console.ReadKey();
        }
コード例 #2
0
        public async System.Threading.Tasks.Task <JsonResult> OnGetValidateAsync(string baseUrl, string id)
        {
            ServiceDirectory.Common.Results.ValidationResult result = await APIValidator.Validate(baseUrl, id, new APIValidatorSettings()
            {
                SamplePages = true
            });

            if (result.GetException() != null)
            {
                _logger.LogError(result.GetException(), result.Error);
            }


            return(new JsonResult(result));
        }
コード例 #3
0
        public async Task <Feed> Check(Feed feed)
        {
            var startTime = DateTime.UtcNow;
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            Console.WriteLine($"checking: {feed.Url}; started at: {startTime.ToString("yyyy-MM-ddTHH:mm:ss")}");

            var result = await APIValidator.Validate(feed.Url, string.Empty, new APIValidatorSettings { FirstPageOnly = false, RandomServiceOnly = false });

            stopwatch.Stop();

            var newFeed = new Feed
            {
                Url                 = feed.Url,
                Label               = feed.Label,
                Summary             = feed.Summary,
                OrganisationLabel   = feed.OrganisationLabel,
                OrganisationUrl     = feed.OrganisationUrl,
                DeveloperLabel      = feed.DeveloperLabel,
                DeveloperUrl        = feed.DeveloperUrl,
                ServicePathOverride = feed.ServicePathOverride,
                SchemaType          = feed.SchemaType,

                LastCheck      = startTime,
                CheckIsRunning = false,
                TimeTaken      = stopwatch.ElapsedMilliseconds,

                IsUp = result.IsUp,

                IsServicesValid = result.HasPagination && result.HasPaginationMetaData,
                ServicesMessage = result.ApiIssuesLevel1 == null || !result.ApiIssuesLevel1.Any() ? null : string.Join("\n", result.ApiIssuesLevel1),

                IsServiceExampleValid    = result.IsServiceFound,
                ServiceExampleIdentifier = result.RandomServiceIdentifier,
                ServiceExampleMessage    = result.ApiIssuesLevel2 == null || !result.ApiIssuesLevel2.Any() ? null : string.Join("\n", result.ApiIssuesLevel2),

                IsSearchEnabled      = result.Level2Results != null && result.Level2Results.Any(t => t.Success),
                SearchEnabledMessage = GetSearchResultJson(result.Level2Results),

                Filters = feed.Filters,
            };

            Console.WriteLine($"done: {feed.Url}; took: {stopwatch.ElapsedMilliseconds.ToString("#,###")}ms");

            return(newFeed);
        }