//################################################################################################# public static string DownloadAndProcessGEOProfiles(List <Classes.Content> clist) { string zipName = Path.Combine(zipPath, Program.GuidString + ".zip"); ClearDirectory(tmpPath); Directory.CreateDirectory(tmpPath); Directory.CreateDirectory(zipPath); Directory.CreateDirectory(dataPath); Directory.CreateDirectory(processedPath); foreach (string GDS_accession in clist.Where(cont => cont.download).Select(cont => cont.accession).Distinct()) { string filename = $"{GDS_accession}_full.soft.gz"; if (!Classes.web_scraper.download_soft_file(GDS_accession, Path.Combine(zipPath, $"{GDS_accession}_full.soft.gz"))) { LogController.LogError($"Could not download entry for {GDS_accession}"); continue; } MoveAndExtractFiles(zipPath, dataPath); Classes.PythonProcess.filter_GEOProfiles_soft(Path.Combine(dataPath, $"{GDS_accession}_full.soft"), Path.Combine(processedPath, $"{GDS_accession}_identifier.soft"), Path.Combine(processedPath, $"{GDS_accession}_data.soft")); } ZipFile.CreateFromDirectory(processedPath, zipName); ClearDirectory(dataPath); ClearDirectory(processedPath); return(zipName); }
//################################################################################################# public IActionResult LoadSessionFromFile(Models.SessionModel sessionModel) { Program.sessionModel.validationMessage = String.Empty; Program.sessionModel.valError = false; if ((sessionModel.file != null && !sessionModel.file.FileName.EndsWith(".xml")) || (!String.IsNullOrEmpty(sessionModel.fileName) && !sessionModel.fileName.EndsWith(".xml"))) { Program.sessionModel.validationMessage = HelperController.GetMessage("Session.Err.WrongType").txt; Program.sessionModel.valError = true; return(Session()); } if (sessionModel.file != null) { try { var result = new StringBuilder(); using (var reader = new StreamReader(sessionModel.file.OpenReadStream())) { while (reader.Peek() >= 0) { result.AppendLine(reader.ReadLine()); } } var filestring = result.ToString(); Program.indexModel.FilterList = GetFiltersFromXml(Controllers.XmlController.GetXml(filestring)); } catch (Exception ex) { LogController.LogError(String.Format(HelperController.GetMessage("SessionController.Err.LoadSessionFromFile(Model)1").txt, ex.ToString())); Program.sessionModel.validationMessage = HelperController.GetMessage("SessionController.Err.LoadSessionFromFile(Model)1").ext; Program.sessionModel.valError = true; return(Session()); } } else { try { Program.indexModel.FilterList = GetFiltersFromXml(Controllers.XmlController.GetXml(HelperController.ConvertBase64ToUtf8(sessionModel.fileString))); } catch (Exception ex) { LogController.LogError(String.Format(HelperController.GetMessage("SessionController.Err.LoadSessionFromFile(Model)2").txt, ex.ToString())); Program.sessionModel.validationMessage = HelperController.GetMessage("SessionController.Err.LoadSessionFromFile(Model)2").ext; Program.sessionModel.valError = true; return(Session()); } } Program.sessionModel.validationMessage = HelperController.GetMessage("SessionController.Inf.LoadSessionFromFile(Model)").txt; return(Session()); }
//################################################################################################# public static XmlDocument GetXml(string str) { XmlDocument xDoc = new XmlDocument(); try { xDoc.LoadXml(str); } catch (Exception ex) { LogController.LogError(String.Format(HelperController.GetMessage("XmlController.Err.GetXml").txt, ex.ToString())); throw; } return(xDoc); }
public static bool IsValid(string str) { if (!String.IsNullOrEmpty(str)) { try { XmlDocument xDoc = GetXml(str); } catch (Exception ex) { LogController.LogError(String.Format(HelperController.GetMessage("XmlController.Err.IsValid").txt, ex.ToString())); throw; } } return(true); }
//################################################################################################# public IActionResult Index() { LogController.Begin(); try { if (false && Program.indexModel.FilterList == null) { Program.indexModel.FilterList = Controllers.SessionController.LoadSession(); } } catch (Exception ex) { Program.indexModel.FilterList = new Classes.FList(); LogController.LogError(ex.ToString()); } ViewData["Preview"] = GEOMiner.Controllers.HelperController.GetMessage("Index.Inf.Preview").txt; LogController.End(); return(View("~/Views/Home/Index.cshtml", Program.indexModel)); }
public IActionResult Start(Models.IndexModel model, string action) { LogController.Begin(); if (model.FilterList == null | (model.FilterList != null && model.FilterList.flist == null)) { var msg = HelperController.GetMessage("Index.Err.NoFilter"); LogController.LogError(msg.txt); Program.indexModel.ExceptionMessage = msg.txt; return(RedirectToAction("Index", "Home")); } SessionController.SaveSession(model.FilterList); Program.indexModel.ExceptionMessage = model.ExceptionMessage; Program.indexModel.ErrorFilterList = model.ErrorFilterList; if (!String.IsNullOrEmpty(action) && action != "Start") { Program.indexModel.FilterList.Remove(action); return(RedirectToAction("Index", "Home")); } Program.indexModel.FilterList = new Classes.FList(model.FilterList); //da "GetContent" nicht statisch try { queryController qController = new queryController(); Program.indexModel.ContentList = new List <Classes.Content>(); Program.indexModel.ContentList = qController.GetContent(Program.indexModel.FilterList.flist); } catch (Exception ex) { LogController.LogError(String.Format(HelperController.GetMessage("Helper.Err.QueryController").txt, ex.ToString())); Program.indexModel.ExceptionMessage = HelperController.GetMessage("Helper.Err.QueryController").ext; } return(RedirectToAction("Index", "Home")); }
//################################################################################################# public static Classes.FList LoadSessionFromFile(string file, bool usedef) { XmlDocument doc = new XmlDocument(); try { doc = Controllers.FileController.LoadXmlFromFile(file); if (doc.ChildNodes.Count == 0 && usedef) { return(LoadSessionFromFile("DefaultFilters.xml", false)); } } catch (Exception ex) { LogController.LogError(String.Format(HelperController.GetMessage("SessionController.Err.LoadSessionFromFile(string,bool)").txt, ex.ToString())); throw; } return(GetFiltersFromXml(doc)); }
//################################################################################################# public static Message GetMessage(string msgcode) { try { Controllers.LogController.Begin(); StartZeit = DateTime.Now; LogController.LogMessage(string.Format("GetMessage: MsgCode: '{0}', Language:'{1}'", msgcode, language)); Message msg = new Message(); string strFilename = Path.Combine("Config", "Messages.xml"); XmlTextReader reader = new XmlTextReader("Messages.xml"); XmlDocument doc = new XmlDocument(); try { doc.Load(strFilename); } catch { if (System.IO.File.Exists(strFilename)) { Controllers.LogController.LogError($"Error loading {strFilename}."); } else { Controllers.LogController.LogError($"Could not load {strFilename}. File does not exist"); } } XmlNode messages = doc.SelectSingleNode("messages"); foreach (XmlNode node in messages.SelectNodes("message")) { if (node.SelectSingleNode("msgcode") == null) { continue; } if (!node.SelectSingleNode("msgcode").InnerText.ToLower().Equals(msgcode.ToLower())) { continue; } if (node.SelectSingleNode("text") != null) { if (node.SelectSingleNode(string.Format("text/{0}", language)) != null) { msg.txt = node.SelectSingleNode("text/" + language).InnerText; } } if (msg.txt == "" || msg.txt == null) { msg.txt = string.Format("{0} for lanuage '{1}' isn't available.", msgcode, language); LogController.LogError(string.Format("{0} for lanuage '{1}' isn't available.", msgcode, language)); } if (node.SelectSingleNode("extern") != null) { if (node.SelectSingleNode(string.Format("extern/{0}", language)) != null) { msg.ext = node.SelectSingleNode("extern/" + language).InnerText; } } if (node.SelectSingleNode("type") != null) { msg.type = node.SelectSingleNode("type").Value; } else { msg.type = "default"; } break; } Controllers.LogController.End(String.Format("verstrichene Zeit: {0}", DateTime.Now - StartZeit)); return(msg); } catch { Controllers.LogController.LogError("Message could not be produced"); Message msg = new Message(); msg.txt = "'Empty'"; return(msg); } }
//################################################################################################# public IActionResult UploadFile(Models.UploadModel uploadModel) { try { Controllers.LogController.Begin(); StartZeit = DateTime.Now; Program.uploadModel.ExceptionMessage = null; Program.uploadModel.Step = 1; Directory.CreateDirectory(tmpPath); Directory.CreateDirectory(dataPath); Directory.CreateDirectory(csvPath); Directory.CreateDirectory(processedPath); if (uploadModel.file != null) { try { using (var stream = System.IO.File.Create(Path.Combine(dataPath, uploadModel.file.FileName))) { uploadModel.file.CopyTo(stream); } } catch (Exception ex) { LogController.LogError(String.Format(HelperController.GetMessage("UploadController.Err.UploadFile1").txt, ex.ToString())); Program.uploadModel.ExceptionMessage = HelperController.GetMessage("UploadController.Err.UploadFile1").ext; return(Upload()); } } else { try { if (uploadModel.fileString.IndexOf("data:") >= 0) { uploadModel.fileString = Regex.Replace(uploadModel.fileString, "data:([^,]+)", String.Empty); uploadModel.fileString = uploadModel.fileString.Remove(0, 1); } System.IO.File.WriteAllBytesAsync(Path.Combine(dataPath, uploadModel.fileName), Convert.FromBase64String(uploadModel.fileString)); } catch (Exception ex) { LogController.LogError(String.Format(HelperController.GetMessage("UploadController.Err.UploadFile2").txt, ex.ToString())); Program.uploadModel.ExceptionMessage = HelperController.GetMessage("UploadController.Err.UploadFile2").ext; return(Upload()); } } Program.uploadModel.FileList = new List <Classes.File>(); FileController.MoveAndExtractFiles(dataPath, csvPath); FileController.MoveAndExtractFiles(csvPath, processedPath); LogController.End(String.Format("verstrichene Zeit: {0}", DateTime.Now - StartZeit)); return(Preview(processedPath)); } catch (Exception ex) { LogController.LogError(String.Format(HelperController.GetMessage("UploadController.Err.Total").txt, ex.ToString())); Program.uploadModel.ExceptionMessage = HelperController.GetMessage("UploadController.Err.Total").ext; FileController.ClearDirectory(@"C:\temp\tmp_upload_" + Program.GuidString); Program.uploadModel.FileList = null; return(Upload()); } }