public static void CreateFromDirectory(TaxonTreeNode _root, string path) { TaxonSearch searchTool = new TaxonSearch(_root, true, true); int countFound = 0; int countNotFound = 0; string[] files = Directory.GetFiles(path, "*.txt"); string logFilename = Path.Combine(TaxonUtils.GetTaxonLocationPath(), "CreateFromDirectory.log"); using (StreamWriter log = new StreamWriter(logFilename)) { using (ProgressDialog progressDlg = new ProgressDialog()) { progressDlg.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; progressDlg.Show(); ProgressItem parseFiles = progressDlg.Add("parseFiles", "", 0, files.Length); foreach (string file in files) { parseFiles.Inc(file); log.WriteLine("Import " + file + ":"); France.Departement dep = France.Data.Departements.GetDepartementFromName(Path.GetFileNameWithoutExtension(file)); if (dep == null) { log.WriteLine(" associated departement not found"); continue; } TaxonList.ImportFileResult resultImport = TaxonList.ImportFile(file, searchTool); log.WriteLine(" " + resultImport.TaxonsFound + " taxons found"); log.WriteLine(" " + resultImport.TaxonNotFound + " taxons not found"); countFound += resultImport.TaxonsFound; countNotFound += resultImport.TaxonNotFound; TaxonList taxons = new TaxonList(); taxons.FromTaxonTreeNodeList(resultImport.List); taxons.HasFile = true; taxons.FileName = Path.Combine(TaxonUtils.GetTaxonLocationPath(), dep.Id + ".xml"); taxons.Save(); } } } string message = "Create location data from directory " + path + ": \n"; message += String.Format(" taxons found: {0}\n", countFound); message += String.Format(" taxons not found: {0}\n", countNotFound); message += String.Format("for more details, look at " + logFilename + " file, and all other generated logs"); Loggers.WriteInformation(LogTags.Location, message); }
public static TaxonLocations Load(TaxonTreeNode _root) { string path = TaxonUtils.GetTaxonLocationPath(); return(!Directory.Exists(path) ? null : new TaxonLocations(path, _root)); }