Пример #1
0
        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());
        }
Пример #2
0
        //#################################################################################################
        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));
        }
Пример #3
0
        //#################################################################################################
        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));
        }
Пример #4
0
        //#################################################################################################
        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));
        }
Пример #5
0
        //#################################################################################################
        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);
        }
Пример #6
0
        //#################################################################################################
        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();
        }
Пример #7
0
        //#################################################################################################
        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());
            }
        }