void ExportSounds(TaxonDesc desc, ExportData _data) { _data.ProgressItem.Update(_data.ProgressItem.Current + 1); if (desc.HasSound) { CopyFile(TaxonUtils.GetSoundFullPath(desc), true, _data); } }
void RemoveUnderscore(TaxonDesc _desc) { if (!_desc.RefAllNames.Contains('_')) { return; } _desc.RefMultiName = new Helpers.MultiName(_desc.RefAllNames.Replace('_', ' ')); NumNameChanged++; }
void ComputeSubGenreFirst(TaxonDesc _desc) { if (_desc.ClassicRank != ClassicRankEnum.None) { return; } if (!_desc.RefMultiName.Main.ToLower().Contains("subgenus")) { return; } _desc.ClassicRank = ClassicRankEnum.SousGenre; _Data.NewSousGenre++; _Data.Writer.WriteLine(" " + _desc.RefMultiName.Main); }
void ExportPhotos(TaxonDesc desc, ExportData _data) { _data.ProgressItem.Update(_data.ProgressItem.Current + 1); if (desc.Images == null) { return; } foreach (TaxonImageDesc image in desc.Images) { if (image.IsALink) { continue; } ImageCollection collection = image.GetCollection(); if (collection == null) { _data.Log.WriteLine("error: " + desc.RefMainName + " image collection is null"); continue; } CopyCollectionInfo(collection.Path, _data); CopyFile(image.GetPath(desc), false, _data); } }
void clear(TaxonDesc _desc) { _desc.ClassicRank = ClassicRankEnum.None; }
public void Activate() { OpenFileDialog ofd = new OpenFileDialog { Filter = "Species list (*.txt)|*.txt", Multiselect = false, AddExtension = true }; if (ofd.ShowDialog() != DialogResult.OK) { return; } if (!File.Exists(ofd.FileName)) { return; } string shortName = Path.GetFileNameWithoutExtension(ofd.FileName); int totalLines = 0; int ErrorNoTwoWords = 0; int ErrorGenreNotFound = 0; int ErrorGenreFoundMoreThanOnce = 0; int WarningSpeciesAlreadyInGenre = 0; int NoErrors = 0; string logFilenameErrors = Path.Combine(TaxonUtils.GetLogPath(), "ImportSpeciesOnGenre_" + shortName + "_errors.log"); using (StreamWriter log = new StreamWriter(logFilenameErrors)) { TaxonSearch searchTool = new TaxonSearch(TaxonUtils.OriginalRoot, false, false); searchTool.Init((n) => { if (n.Desc.IsUnnamed) { return; } if (n.Desc.ClassicRank == ClassicRankEnum.Genre) { searchTool.Add(n.Desc.RefMultiName.Main, n); } }); using (StreamReader file = new StreamReader(ofd.FileName)) { string line; while ((line = file.ReadLine()) != null) { if (string.IsNullOrWhiteSpace(line)) { continue; } line = line.Trim(); totalLines++; List <string> names = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); if (names.Count != 2) { log.WriteLine("Error, species must have two names: " + line); ErrorNoTwoWords++; continue; } List <TaxonTreeNode> searchResult = searchTool.FindAll(names[0]); if (searchResult == null || searchResult.Count == 0) { log.WriteLine("Error, does not found genre for: " + line); ErrorGenreNotFound++; continue; } if (searchResult.Count > 1) { log.WriteLine("Error, more than one genre for: " + line); ErrorGenreFoundMoreThanOnce++; continue; } string searchString = line.ToLower().Replace('-', ' '); TaxonTreeNode taxonGenre = searchResult[0]; bool speciesFound = false; foreach (TaxonTreeNode child in taxonGenre.Children) { string formated = child.Desc.RefMultiName.Main.ToLower().Replace('-', ' '); if (formated == searchString) { speciesFound = true; } } if (speciesFound) { log.WriteLine("Warning, species already exists: " + line); WarningSpeciesAlreadyInGenre++; continue; } TaxonDesc newTaxon = new TaxonDesc(line) { ClassicRank = ClassicRankEnum.Espece }; taxonGenre.AddChild(new TaxonTreeNode(newTaxon)); NoErrors++; } } } string message = "Importing 'species on genre' from: " + ofd.FileName + "\n"; message += String.Format(" Total lines: {0}\n", totalLines); message += String.Format(" lines with species with less or more than two words : {0}\n", ErrorNoTwoWords); message += String.Format(" lines without associated genre : {0}\n", ErrorGenreNotFound); message += String.Format(" lines with more than one associated genre: {0}\n", ErrorGenreFoundMoreThanOnce); message += String.Format(" lines with species already in genre: {0}\n", WarningSpeciesAlreadyInGenre); message += String.Format(" lines with imported species: {0}\n", NoErrors); message += String.Format("for more details, look at ImportSpeciesOnGenre_{0}_Errors.log files", shortName); Loggers.WriteInformation(LogTags.Data, message); }