コード例 #1
0
        public async Task <IActionResult> ScrapRepository(string repositorySiteUrl)
        {
            try
            {
                Uri repositoryUri;

                if (Uri.TryCreate(repositorySiteUrl, UriKind.Absolute, out repositoryUri))
                {
                    var scrapService = new ScrapService(repositoryUri);

                    var result = await scrapService.CollectData();

                    return(new OkObjectResult(result));
                }
                else
                {
                    throw new ScrapException("MSG_0001");
                }
            }
            catch (ScrapException ex)
            {
                return(new NotFoundObjectResult(JsonConvert.SerializeObject(new ExceptionModel(ex))));
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
                return(new BadRequestObjectResult("Internal Server Error."));
            }
        }
コード例 #2
0
ファイル: ScrapTests.cs プロジェクト: joulisroots/ScrapApi
        public async Task CollectDataTesteSuccess()
        {
            var uriSite = new Uri("https://github.com/pixijs/pixi.js");
            var service = new ScrapService(uriSite);

            var result = await service.CollectData();

            Assert.True(result.Any());
        }