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)); }
public void SituationToSituationGpuTest() { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var selectedSituation = noSqlWorker.GetSituation(31485076); var result = Tools.SituationToSituationGpu(selectedSituation); }
public void SituationValidateTest() { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var selectedSituation = noSqlWorker.GetSituation(12036987); var newSituation = Tools.ValidateSituation(selectedSituation); }
public void SelectTest() { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var list = noSqlWorker.SelectByFilter("name","test1", "", "", "create_date", Convert.ToDateTime("11.06.2016")).GetAwaiter().GetResult(); //var test1 = noSqlWorker.GetSituation(31485076); //var test2 = noSqlWorker.GetSituation(40054951); Assert.Fail(); }
public string GetOneSituation(string idInJson) { var id = JsonConvert.DeserializeObject <int>(idInJson); var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var selectedSituation = noSqlWorker.GetSituation(id); return(new JavaScriptSerializer().Serialize(selectedSituation)); }
public void ToGraphTest() { //load situation var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var selectedSituation = noSqlWorker.GetSituation(13500410); //graph var gw = new GraphWorker(); var output = gw.SituationToGraph(selectedSituation.participants); }
public string SaveSituation(string situationInJson) { var newSituation = JsonConvert.DeserializeObject <Situation>(situationInJson); newSituation.create_date = DateTime.Today; newSituation.id = newSituation.GetHashCode(); var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); noSqlWorker.Insert(newSituation); return(new JavaScriptSerializer().Serialize(newSituation)); }
public void SituationToXmlTest() { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var selectedSituation = noSqlWorker.GetSituation(30544706); var ser = new XmlSerializer(typeof(Situation)); var fullPath = Path.Combine("G://Situation" + ".xml"); var writer = new FileStream(fullPath, FileMode.Create); ser.Serialize(writer, selectedSituation); writer.Close(); }
public void ToCoordinateFromStringGraphTest() { //load situation var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var selectedSituation = noSqlWorker.GetSituation(13500410); //graph var gw = new GraphWorker(); var output = gw.SituationToGraph(selectedSituation.participants); var outputWithCoordinates = gw.MakeGraph(output); var outputCoordinates = gw.FillCoordinates(selectedSituation, outputWithCoordinates); }
//save to bundle public HttpResponseMessage Post([FromBody] Situation situation) { var newSituation = situation; newSituation.create_date = DateTime.Today; newSituation.id = newSituation.GetHashCode(); newSituation = Tools.ValidateSituation(newSituation); var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); noSqlWorker.Insert(newSituation); return(Request.CreateResponse(HttpStatusCode.OK, newSituation.id)); }
public string GetSituationBundle(string filter) { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var bundle = noSqlWorker.Select(); var liteBundle = bundle.Select(situation => new liteBundleElement { id = situation.id, name = situation.name, type = situation.type, date = situation.create_date.ToShortDateString() }).ToList(); return(new JavaScriptSerializer().Serialize(liteBundle)); }
public string GetOneSituationNewCoordinate(string idInJson) { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var id = JsonConvert.DeserializeObject <int>(idInJson); var selectedSituation = noSqlWorker.GetSituation(id); //graph var gw = new GraphWorker(); var output = gw.SituationToGraph(selectedSituation.participants); var outputWithCoordinates = gw.MakeGraph(output); var outputSituation = gw.FillCoordinates(selectedSituation, outputWithCoordinates); return(new JavaScriptSerializer().Serialize(outputSituation)); }
public void RoughSearchTest() { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var test1 = noSqlWorker.GetSituation(31485076); var test2 = noSqlWorker.GetSituation(40054951); var testGpu1 = Tools.SituationToSituationGpu(test1); var testGpu2 = Tools.SituationToSituationGpu(test2); SituationSearcher ss = new SituationSearcher(); int[,] resultCompared; double roughMark; double roughLimit = 100; ss. ss.RoughSearch(testGpu1.Participants, testGpu1.Attributes, testGpu2.Participants, testGpu2.Attributes, roughLimit, out roughMark, out resultCompared); }
public void AccurateSearchTest() { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var test1 = noSqlWorker.GetSituation(28805302); var test2 = noSqlWorker.GetSituation(62476613); var testGpu1 = Tools.SituationToSituationGpu(test1); var testGpu2 = Tools.SituationToSituationGpu(test2); SituationSearcher ss = new SituationSearcher(); int[,] resultCompared; int[,] accurateCompared; double roughMark; double roughLimit = 100; ss.RoughSearch(testGpu1.Participants, testGpu1.Attributes, testGpu2.Participants, testGpu2.Attributes, roughLimit, out roughMark, out resultCompared); //ss.AccurateSearch(testGpu1.Connections,testGpu2.Connections,resultCompared,out accurateCompared); }
public IHttpActionResult GetAllSituations(Situation situationIn) { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var bundle = noSqlWorker.Select(); SituationSearcher ss = new SituationSearcher(); ss.SituationsInBase = bundle; ss.SearchStart(situationIn); var liteBundle = bundle.Select(situation => new LiteBundleElement { id = situation.id, name = situation.name, type = situation.type, rate = situation.rate }).ToList(); return(Ok(liteBundle)); }
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)); }
//get bundle by filter //search start public HttpResponseMessage Post([FromBody] Situation situationIn) { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var bundle = noSqlWorker.Select(); var ss = new SituationSearcher { SituationsInBase = bundle }; ss.SearchStart(situationIn); bundle = ss.SituationsInBase; var liteBundle = bundle.Select(situation => new LiteBundleElement { id = situation.id, name = situation.name, type = situation.type, rate = situation.rate }).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, liteBundle)); }
public async Task <IEnumerable <liteBundleElement> > GetAllSituations([FromBody] Filter filter) { List <Situation> bundle; if (filter.sourceType) { bundle = OwlWorker.CurrentSituationBaseFromOwl; } else { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var name = filter.name != "" ? "name" : ""; var type = filter.type != "" ? "type" : ""; var date = filter.date != "" ? "create_date" : ""; DateTime dateIn; if (DateTime.TryParse(filter.date, out dateIn)) { DateTime.TryParse(filter.date, out dateIn); bundle = await noSqlWorker.SelectByFilter(name, filter.name, type, filter.type, date, dateIn); } else { bundle = await noSqlWorker.SelectByFilter(name, filter.name, type, filter.type, date, DateTime.Now); } } var liteBundle = bundle.Select(situation => new liteBundleElement { id = situation.id, name = situation.name, type = situation.type, date = situation.create_date.ToShortDateString() }).ToList(); return(liteBundle); }