internal void StartImageImport() { if (worksheetImages != null) { try { for (int i = 2; i <= worksheetImages.Dimension.Rows; i++) { if (worksheetImages.Cells[i, 1].Value != null) { Image imageInst = _parseImageRow(i); if (imageInst != null) { _saveImage(imageInst); _contextObs.SaveChanges(); } } } } catch (Exception e) { Logger.Error(e, "Error @ Image Import"); } } }
private void ClearDatabaseTable() { using (_dbContext) { _dbContext.CoordinatesWrapper.RemoveRange(_dbContext.CoordinatesWrapper); _dbContext.SaveChanges(); } }
public void updateTaxIdsInImageAndObs() { Dictionary <string, int> taxIdName_dict = _infContext.Taxon.Where(o => o.TaxonId != null && o.TaxonName != null && o.TaxonomyStateId == 301).Select(t => new { t.TaxonId, t.TaxonName }).ToDictionary(x => x.TaxonName, y => y.TaxonId); List <Observation> obs = _obsContext.Observation.Where(o => o.TaxonName != null).ToList(); List <Image> img = _obsContext.Image.Where(o => o.TaxonName != null).ToList(); foreach (Observation o in obs) { if (taxIdName_dict.TryGetValue(o.TaxonName, out int val)) { o.TaxonId = val; } } foreach (Image i in img) { if (taxIdName_dict.TryGetValue(i.TaxonName, out int val)) { i.TaxonId = val; } } _obsContext.SaveChanges(); }
private void AddCoordinatesToDatabase(CoordinatesWrapper coordinates) { _dbContext.CoordinatesWrapper.Add(coordinates); _dbContext.SaveChanges(); }