public IActionResult Show(int id) { try { //все точки List <string> data = GetData.ReadFile(id, this.hostingEnvironment); //все пики List <string> peaks = GetData.GetRPeaks(id, this.hostingEnvironment); //все результаті корреляции List <double> correlationRes = Correlation.CorrelationPoints(data, peaks); //модель ответа пользователю JsonResultModel model = new JsonResultModel { Points = data, Peaks = peaks, CorelationResult = correlationRes }; return(this.Json(model)); } catch (Exception ex) { return(this.BadRequest(ex.Message)); } }
public IActionResult Show(int id) { //все точки List <string> data = new List <string>(); //все пики List <string> peaks = new List <string>(); //папка хранения файлов string folderName = "Upload"; string webRootPath = this.hostingEnvironment.WebRootPath; //путь к этой папке string path = Path.Combine(webRootPath, folderName); //путь файла path = Path.Combine(path, id + ".dat"); //достаем данные из датовского файла try { using (FileStream stream = new FileStream(path, FileMode.Open)) { try { //Correlation.Pearson(new List<double> { 1, 2, 3 }, new List<double> { 1, 2 }); data = Reader.GetData(stream); } catch (Exception ex) { return(this.Json(new string[] { "Cannot convert data!", ex.Message })); } } } catch (Exception ex) { return(this.Json(new string[] { "Cannot open file!", ex.Message })); } //путь файла с пиками string path2 = Path.Combine(this.hostingEnvironment.ContentRootPath, "Rpeaks.txt"); //заносим пики в список try { using (StreamReader stream = new StreamReader(path)) { try { //var peaksDetection = new PeaksDetection(); //peaksDetection.GetRPeaks(path); //peaks = peaksDetection.RPeaksToList(path2); PeaksDetection.GetRPeaks(path, path2); // peaks = PeaksDetection.RPeaksToList(path2); } catch (Exception ex) { return(this.Json(new string[] { "Cannot get peaks!", ex.InnerException.Message })); } } } catch (Exception ex) { return(this.Json(new string[] { "Cannot open file!", ex.Message })); } List <double> correlationRes = Correlation.CorrelationPoints(data, peaks); JsonResultModel model = new JsonResultModel { Points = data, Peaks = peaks, CorelationResult = correlationRes }; return(this.Json(model)); }