public void Run(int size)
        {
            _logger.LogDebug("Running {0}...", GetType().Name);
            _logger.LogDebug("Config info:");
            _logger.LogDebug("\trepository.repositoryUrl={0}", _repositoryUrl);
            _logger.LogDebug("\tbenchmark.rdfFilesPath={0}", _rdfFilesPath);
            _logger.LogDebug("\tsize={0}", size);

            var filesContent = _readFileService.ReadFilesContent(_rdfFilesPath, size);

            foreach (var fileContent in filesContent)
            {
                try
                {
                    Block block = _blockService.CreateBlock(
                        fileContent.Key,
                        fileContent.Value,
                        RdfFormat.TURTLE);
                }
                catch (CreatingBlockException ex)
                {
                    throw new BenchmarkException("Exception was thrown while creating block.", ex);
                }
            }

            _logger.LogDebug("Finishing running {}...", GetType().Name);
        }
Пример #2
0
        public ActionResult Create(BlockModel model)
        {
            if (model.File != null && model.File.ContentLength > 0)
            {
                var fileName = Path.GetFileName(model.File.FileName);
                var path     = Path.Combine(Server.MapPath("~/Upload/Tab" + model.TAB + "/"), fileName);
                model.File.SaveAs(path);
                model.IMAGE = fileName;
            }
            model.CONTENT = HttpUtility.HtmlDecode(model.CONTENT);
            var check = _blockStoreService.CreateBlock(model);
            var msg   = check
                ? "Add new Block Successfully"
                : string.Format("The Block ID {0} is exited.", model.ID);

            return(Json(msg));
        }
 public IActionResult CreateBlock([FromQuery] string graphIri, string rdfGraphContent)
 {
     _logger.LogDebug("[POST] block/create ? graphIri={}", graphIri);
     _logger.LogTrace("<rdfGraphContent>\n{}\n</rdfGraphContent>", rdfGraphContent);
     try
     {
         var block = _blockService.CreateBlock(graphIri, rdfGraphContent, RdfFormat.TURTLE);
         _logger.LogDebug("Block created successfully. Broadcasting change.");
         _logger.LogTrace("\tCreated block details: {}", block);
         _peerToPeerService.BroadcastBlockCreation(MessageType.RESPONSE_BLOCKCHAIN, block);
         return(Ok(block.BlockHeader));
     }
     catch (CreatingBlockException ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Пример #4
0
 public void RunBenchmark(Dictionary <string, string> filesContent)
 {
     foreach (var graphIriToFileContent in filesContent)
     {
         try
         {
             Block block = _blockService.CreateBlock(
                 graphIriToFileContent.Key,
                 graphIriToFileContent.Value,
                 RdfFormat.TURTLE);
         }
         catch (CreatingBlockException ex)
         {
             _logger.LogWarning(ex, "Exception was thrown while creating block.");
             throw new BenchmarkException("Exception was thrown while creating block.", ex);
         }
     }
 }
        public void Run()
        {
            var rawRdf = File.ReadAllText("c:\\data\\ontologies\\go.nt");

            _blockService.CreateBlock("http://go.obo.org/", rawRdf, RdfFormat.N_TRIPLES);
        }