// GET: Datasets public ActionResult Index() { var discretistationFileHandler = new Discretistation.FileHandler(); var datasetList = datasetRepository.GetAll(); string name = User.Identity.GetUserName(); List <ViewPermissions> vpList = new List <ViewPermissions>(); var viewPermissions = db.ViewPermissions.Where(u => u.UserName == name); foreach (ViewPermissions vp in viewPermissions) { vpList.Add(vp); } foreach (var dataset in datasetList) { foreach (var disc in dataset.Discretizations) { discretizationRepository.Edit(disc); } } discretizationRepository.SaveChanges(); var testStuff = datasetRepository.GetAll().Where(item => item.Owner.Email == User.Identity.Name).ToList(); DatasetIndexViewModel datasetIndexViewModel = new DatasetIndexViewModel() { Datasets = datasetRepository.GetAll(), ViewPermissionsRecords = vpList }; return(View(datasetIndexViewModel)); }
//TODO public string SendToDiscretization(SendDiscretizationViewModel sendDiscretizationViewModel) { string[] methodsList = Request.Form["Methods"].Split(','); var knowledgeBasedMethods = Request.Form["KnowledgedBasedMethods"].Split(','); FileTransferrer fileTransferrer = new FileTransferrer(); Dataset dataset = db.Datasets.Find(sendDiscretizationViewModel.id); string currentUserId = User.Identity.GetUserId(); ApplicationUser currentUser = db.Users.FirstOrDefault(y => y.Id == currentUserId); // Check that there are *not* knowledge based methods in the request if (methodsList[0] != "") { discretizationService.Discretize(methodsList, datasetService.getPath(dataset.DatasetID), id); List <Discretization> discretizations = discretizationService.CreateDiscretizations(dataset, methodsList, id, datasetService.getPath(dataset.DatasetID)); for (int i = 0; i < discretizations.Count; i++) { discretizations[i].Owner = currentUser; discretizationRepository.Add(discretizations[i]); } } // Knowledge based methods with files uploaded if (Request.Files.Count > 0) { foreach (var knowledgeBasedMethod in knowledgeBasedMethods) { var knowledgeBasedMethodSplit = knowledgeBasedMethod.ToString().Split('_'); var methodName = knowledgeBasedMethodSplit[0]; var fileName = knowledgeBasedMethodSplit[knowledgeBasedMethodSplit.Length - 1]; var maxGap = knowledgeBasedMethodSplit[1]; var windowSize = knowledgeBasedMethodSplit[2]; var statesFilyBytes = fileTransferrer.GetBytesFromFile(Request.Files[fileName]); var methodDownloadPath = fileTransferrer.ExpertDataset(dataset.Path, methodName + "/" + maxGap + "_" + windowSize, statesFilyBytes); Discretization d = new Discretization() { Dataset = dataset, DownloadPath = methodDownloadPath, Visibility = "", Type = "Discretized", Owner = currentUser, FullName = MethodEncodingToMethodName[methodName], ParametersIsReady = "In Progress" }; db.Discretizations.Add(d); } } discretizationRepository.SaveChanges(); return("Discretizing..."); }