コード例 #1
0
ファイル: UpdateController.cs プロジェクト: HarelM/Site
        public async Task <IActionResult> PostUpdateData(UpdateRequest request)
        {
            if (!RebuildSemaphore.WaitOne(0))
            {
                return(BadRequest("Can't run two full updates in parallel"));
            }
            try
            {
                if (!IsRequestLocal())
                {
                    return(BadRequest("This operation can't be done from a remote client, please run this from the server"));
                }
                if (request == null ||
                    request.Routing == false &&
                    request.Highways == false &&
                    request.PointsOfInterest == false &&
                    request.UpdateOsmFile == false &&
                    request.DownloadOsmFile == false &&
                    request.Images == false &&
                    request.SiteMap == false)
                {
                    request = new UpdateRequest
                    {
                        Routing          = true,
                        Highways         = true,
                        PointsOfInterest = true,
                        UpdateOsmFile    = true,
                        DownloadOsmFile  = true,
                        SiteMap          = true,
                        Images           = true
                    };
                    _logger.LogInformation("No specific filters were applied, updating all databases.");
                }
                _logger.LogInformation("Starting updating site's databases according to request: " + JsonConvert.SerializeObject(request));
                await _osmLatestFileFetcherExecutor.Update(request.DownloadOsmFile, request.UpdateOsmFile);

                _logger.LogInformation("Update OSM file completed.");

                await _databasesUpdaterService.Rebuild(request);

                _logger.LogInformation("Finished updating site's databases according to request");
                return(Ok());
            }
            finally
            {
                RebuildSemaphore.Release();
            }
        }
コード例 #2
0
        public void TestRebuild_ShouldRebuildHighwaysAndPoints()
        {
            var adapter = Substitute.For <IPointsOfInterestAdapter>();

            adapter.GetPointsForIndexing().Returns(new List <Feature>());
            _pointsOfInterestAdapterFactory.GetBySource(Arg.Any <string>()).Returns(adapter);
            _elasticSearchGateway.GetExternalPoisBySource(Arg.Any <string>()).Returns(new List <Feature>());
            _featuresMergeExecutor.Merge(Arg.Any <List <Feature> >()).Returns(new List <Feature>());

            _service.Rebuild(new UpdateRequest {
                Highways = true, PointsOfInterest = true, SiteMap = true
            }).Wait();

            _elasticSearchGateway.Received(1).UpdateHighwaysZeroDownTime(Arg.Any <List <Feature> >());
            _elasticSearchGateway.Received(1).UpdatePointsOfInterestZeroDownTime(Arg.Any <List <Feature> >());
            _pointsOfInterestFilesCreatorExecutor.Received(1).Create(Arg.Any <List <Feature> >());
        }