public void load_ppsTest() { ImportFromConstructor ifc = new ImportFromConstructor(); XmlDocument xml = new XmlDocument(); xml.Load(@"C:\Users\Рябов\Desktop\situationfromgraphicconstructor (2).xml"); var newSit = ifc.load_pps(xml.InnerXml); newSit.create_date = DateTime.Today; //newSit.coordinates = new List<Coordinate>(); //var gw = new GraphWorker(); //newSit = gw.FillCoordinates(newSit, gw.MakeGraph(gw.SituationToGraph(newSit.participants))); //var noSqlWorker = new NoSqlWorker(); //noSqlWorker.Initialization(); //noSqlWorker.Insert(newSit); }
public async Task <IHttpActionResult> PostFromConstructor() { if (!Request.Content.IsMimeMultipartContent()) { return(BadRequest()); } var provider = new MultipartMemoryStreamProvider(); // путь к папке на сервере string root = HttpContext.Current.Server.MapPath("~/App_Data/"); await Request.Content.ReadAsMultipartAsync(provider); Situation newSit = null; foreach (var file in provider.Contents) { var filename = file.Headers.ContentDisposition.FileName.Trim('\"'); var owlString = file.ReadAsStringAsync(); ImportFromConstructor ifc = new ImportFromConstructor(); newSit = ifc.load_pps(owlString.Result); newSit.create_date = DateTime.Today; newSit.coordinates = new List <Coordinate>(); var gw = new GraphWorker(); newSit = gw.FillCoordinates(newSit, gw.MakeGraph(gw.SituationToGraph(newSit.participants))); var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); noSqlWorker.Insert(newSit); //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); //} } if (newSit == null) { return(NotFound()); } return(Ok(newSit)); }