public List <Classes.Content> GetContent(List <Classes.Filter> flist) { LogController.Begin(); StartZeit = DateTime.Now; eSearch = new Classes.ESearch(Program.indexModel.database.KeyName); eSummary = new Classes.ESummary(Program.indexModel.database.KeyName); try { PassQuery(flist, eSearch); } // fills Webenvironment and Ids catch { Controllers.LogController.LogError($"Query via Flist failed with {flist.Count()} elements"); throw; }; try { PassWebEnv(this.WebEnvironment, eSummary); } // fills titles and summaries catch (Exception ex) { Controllers.LogController.LogError($"Query via WebENv failed with {this.WebEnvironment} for utility 'esummary', ERROR: {ex.ToString()}"); throw; }; LogController.End(String.Format("verstrichene Zeit: {0}", DateTime.Now - StartZeit)); return(GetContent()); }
//################################################################################################# public List <Classes.Content> GetContent() { LogController.Begin(); StartZeit = DateTime.Now; List <Classes.Content> ret = new List <Classes.Content>(); if (summaries == null) { return(ret); } var s = summaries.GetEnumerator(); while (s.MoveNext()) { DateTime start = DateTime.Now; var el = s.Current; var newContent = new Classes.Content(); int c; Int32.TryParse(el.Attribute("uid").Value, out c); newContent.ID = c; using (XmlReader reader = el.CreateReader()) { while (reader.Read()) { switch (reader.NodeType, reader.Name, Program.indexModel.database.KeyName) {
//################################################################################################# public void PassQuery(List <GEOMiner.Classes.Filter> inputs, Classes.EUtilities u) { LogController.Begin(); StartZeit = DateTime.Now; string query = "&term="; List <String> existFilters = new List <String>(); foreach (GEOMiner.Classes.Filter input in inputs) { if (existFilters.Contains(input.name)) { continue; } if (query != "&term=") { query = query + "+AND+"; } Classes.Filter tmp = input; foreach (GEOMiner.Classes.Filter i in inputs) { if (i.id != input.id && i.name == input.name) { tmp.value = tmp.value + "," + i.value; } } query = query + tmp.GetValueForQuery(Program.indexModel.database.KeyName); existFilters.Add(input.name); } query = query.Trim().Replace(' ', '+'); query = FormulateRequest(query, u.EType, Program.indexModel.database.KeyName); try { (this.WebEnvironment, this.IDs) = u.SendRequest(query); } catch (Exception ex) { Controllers.LogController.LogError($"Query failed with {query} for utility '{u.EType}' , ERROR: {ex.ToString()} "); }; LogController.End(String.Format("verstrichene Zeit: {0}", DateTime.Now - StartZeit)); }
//################################################################################################# public void PassWebEnv(String keys, Classes.EUtilities u) { LogController.Begin(); StartZeit = DateTime.Now; // WebEnv keys best be stored as fully realised request Strings as soon as they get parsed String query = this.FormulateRequest(keys, u.EType, Program.indexModel.database.KeyName); try { this.summaries = u.SendRequest_(query); } catch { Controllers.LogController.LogError($"Query failed with {query} for utility '{u.EType}' "); }; LogController.End(String.Format("verstrichene Zeit: {0}", DateTime.Now - StartZeit)); }
//################################################################################################# 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 String FormulateRequest(String request, String request_type = "esearch", String database = "geoprofiles", String version = "&version=2.0") { LogController.Begin(); StartZeit = DateTime.Now; String base_address = $"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/{request_type}.fcgi?db={database}{version}&retmax=1000"; String authenticators = "&tools=GEOMiner&[email protected]&api_key=284c0c6aaa88d90d532e60eed8446e68ce09"; String url = base_address + request + authenticators; if (this.WebEnvironment == null) { url = url + "&usehistory=y"; } Controllers.LogController.LogMessage($"Parsed url: {url}"); LogController.End(String.Format("verstrichene Zeit: {0}", DateTime.Now - StartZeit)); return(url); }
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 void MoveAndExtractFiles(string source, string destination) { LogController.Begin(); foreach (FileInfo fi in new DirectoryInfo(source).GetFiles()) { var newName = ExtractFiles(fi.FullName); if (newName != null && fi.Extension == ".zip") { var t = Path.GetFileName(newName); MoveAndExtractFiles(Path.Combine(source, Path.GetFileName(newName)), destination); continue; } if (newName != null) { var t = Path.Combine(source, Path.GetFileName(newName)); if (new FileInfo(Path.Combine(destination, Path.GetFileName(newName))).Exists) { System.IO.File.Delete(Path.Combine(destination, Path.GetFileName(newName))); } System.IO.File.Move(Path.Combine(source, Path.GetFileName(newName)), Path.Combine(destination, Path.GetFileName(newName))); continue; } if (new FileInfo(Path.Combine(destination, fi.Name)).Exists) { System.IO.File.Delete(Path.Combine(destination, Path.GetFileName(newName))); } System.IO.File.Move(fi.FullName, Path.Combine(destination, fi.Name)); //Program.uploadModel.FileList.Add(fi); } foreach (DirectoryInfo di in new DirectoryInfo(source).GetDirectories()) { MoveAndExtractFiles(di.FullName, destination); } LogController.End(); }
//################################################################################################# public IActionResult AddFilter(string filtername) { LogController.Begin(); Program.indexModel.ErrorFilterList = null; Program.indexModel.ExceptionMessage = null; if (!String.IsNullOrEmpty(filtername)) { try { if (Program.indexModel.FilterList == null) { Program.indexModel.FilterList = new Classes.FList(); } Program.indexModel.FilterList.Add(new Classes.Filter(filtername, "")); } catch (Exception ex) { Program.indexModel.ErrorFilterList = ex.Message; } } return(RedirectToAction("Index", "Home")); }
public IActionResult SaveToCsv(Models.IndexModel indexModel, int newSite = -1, int newCps = -1) { LogController.Begin(); Program.indexModel.ErrorFilterList = indexModel.ErrorFilterList; Program.indexModel.ExceptionMessage = indexModel.ExceptionMessage; int num = 0; //change only the actual shown part of the contentlist for (int i = 0 + Program.indexModel.cps * Program.indexModel.actSite; i < Program.indexModel.ContentList.Count && i < Program.indexModel.cps * (Program.indexModel.actSite + 1); i++) { int j = i % Program.indexModel.cps; Program.indexModel.ContentList[i].download = indexModel.PartialContentList[j].download; if (Program.indexModel.ContentList[i].download) { num++; } } if (num > 5) { Program.indexModel.ExceptionMessage = HelperController.GetMessage("Index.Err.ToManyFiles").txt; return(RedirectToAction("Index", "Home")); } if (newSite >= 0) { return(SetActSite(newSite)); } if (newCps >= 0) { return(SetCps(newCps)); } switch (Program.indexModel.database.KeyName) { case ("geoprofiles"): var zipFile = FileController.DownloadAndProcessGEOProfiles(Program.indexModel.ContentList); if (zipFile != null && System.IO.File.Exists(zipFile)) { var bArray = System.IO.File.ReadAllBytes(zipFile); return(File(bArray, "application/octet-stream", "export.zip")); } else { Controllers.LogController.LogError($"Zipfile could not be accessed at {zipFile}"); } //break; var csv = FileController.WriteListToCsv(Program.indexModel.ContentList); if (csv != null) { var bArray = System.Text.Encoding.UTF8.GetBytes(csv.ToString()); return(File(bArray, "application/octet-stream", "export.csv")); } break; case ("gds"): var processedPath = FileController.DowloadAndProcessGDS(Program.indexModel.ContentList); if (processedPath != null) { return(RedirectToAction("Upload", "Upload")); } break; } return(RedirectToAction("Index", "Home")); }