public IHttpActionResult GetSituation([FromBody] SourceAndId sai)
        {
            Situation selectedSituation;

            if (sai.sourceType)
            {
                selectedSituation = OwlWorker.GetSituation(sai.id);
                var gw = new GraphWorker();

                selectedSituation = gw.FillCoordinates(selectedSituation, gw.MakeGraph(gw.SituationToGraph(selectedSituation.participants)));
            }
            else
            {
                var noSqlWorker = new NoSqlWorker();
                noSqlWorker.Initialization();
                selectedSituation = noSqlWorker.GetSituation(sai.id);
                if ((selectedSituation.coordinates == null) || (selectedSituation.coordinates.Count == 0))
                {
                    selectedSituation.coordinates = new List <Coordinate>();
                    var gw = new GraphWorker();
                    selectedSituation = gw.FillCoordinates(selectedSituation, gw.MakeGraph(gw.SituationToGraph(selectedSituation.participants)));
                }
            }

            if (selectedSituation == null)
            {
                return(NotFound());
            }
            return(Ok(selectedSituation));
        }
示例#2
0
        public async Task <IEnumerable <AbstractClass> > Post()
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                //return;
            }

            var provider = new MultipartMemoryStreamProvider();
            // путь к папке на сервере
            string root = HttpContext.Current.Server.MapPath("~/App_Data/");
            await Request.Content.ReadAsMultipartAsync(provider);

            foreach (var file in provider.Contents)
            {
                var         filename  = file.Headers.ContentDisposition.FileName.Trim('\"');
                var         owlString = file.ReadAsStringAsync();
                XmlDocument xml       = new XmlDocument();
                xml.LoadXml(owlString.Result);
                OwlWorker.LoadIndividuals(xml);
                var result = OwlWorker.LoadOntologyModel(xml).ToList();
                return(result);
                //byte[] fileArray = await file.ReadAsByteArrayAsync();

                //using (System.IO.FileStream fs = new System.IO.FileStream(root + filename, System.IO.FileMode.Create))
                //{
                //    await fs.WriteAsync(fileArray, 0, fileArray.Length);
                //}
            }
            return(null);
            //return Ok("Read success");
        }
示例#3
0
        public void TestMethod1()
        {
            XmlDocument xml = new XmlDocument();

            xml.Load(@"C:\Users\Рябов\Desktop\dts.owl");
            OwlWorker.LoadIndividuals(xml);
            var subject  = OwlWorker.LoadOntologyModel(xml).Where(x => x.Purpose == "Subject");
            var process  = OwlWorker.LoadOntologyModel(xml).Where(x => x.Purpose == "Process");
            var relation = OwlWorker.LoadOntologyModel(xml).Where(x => x.Purpose == "Relation");
        }
示例#4
0
 public SituationGenerator(XmlDocument xml)
 {
     _subjects  = OwlWorker.LoadOntologyModel(xml).Where(x => x.Purpose == "Subject").ToList();
     _procesess = OwlWorker.LoadOntologyModel(xml).Where(x => x.Purpose == "Process").ToList();
     _relations = OwlWorker.LoadOntologyModel(xml).Where(x => x.Purpose == "Relation").ToList();
 }