private void SaveTaxonDescriptionToContext(int?taxonId, int?descKeyId, int?mwTypeId, decimal?minVal = null, decimal?maxVal = null, string descKeyName = null) { if (!TaxonDescriptionExists(taxonId, descKeyId, mwTypeId) || (minVal != null && maxVal == null)) { TaxonDescription taxDescInstance = new TaxonDescription { TaxonId = taxonId.GetValueOrDefault(), DescriptionKeyId = descKeyId.GetValueOrDefault(), DescriptionKeyTypeId = mwTypeId, MinValue = minVal, MaxValue = maxVal }; _contextDet.Add(taxDescInstance); Logger.Debug("--- Saving TaxonDescr {0} ({1}/{2}/{3}) to Context (TaxId/DescId/DescKeyType) ...", descKeyName, taxonId, descKeyId, mwTypeId); SaveToContext(); taxDescKeyCounter++; } else { Logger.Debug("--- Did not add TaxonDescr {0} ({1}/{2}/{3}) to Context (TaxId/DescId/DescKeyType)", descKeyName, taxonId, descKeyId, mwTypeId); Logger.Debug("--- Entity already exists"); } }
/** TODO: Relation Kopf - Unterseite? **/ private void ImportDescKeyGroups() { //Skip Header Row and empty Row //First get "Region" KeyGroups for (int i = 3; i <= worksheetCharacteristics.Dimension.Rows; i++) { //Parse Region Col var cellVal = worksheetCharacteristics.Cells[i, _regionColIndexExcel].Value; if (cellVal != null) { //TODO: switch back when clarified how to import desckeygroups var keyGroupName = cellVal.ToString().Trim(); //var keyGroupName = ConcatKeyGroupName(i); if (!DescKeyGroupNameExists(keyGroupName)) { string keyGroupDataType = null; if (isRegionOnlyKeyGroup(i)) { keyGroupDataType = GetDescKeyGroupDataType(i); } DescriptionKeyGroup descriptionKeyGroup = new DescriptionKeyGroup { KeyGroupName = keyGroupName, DescriptionKeyGroupDataType = keyGroupDataType, VisibilityCategoryId = _MapAmpelType(i) }; _context.Add(descriptionKeyGroup); SaveToContext(); descKeyGroupCounter++; } } } //Lage -> Region Logger.Info("-- Started Lage-Region Import"); ParseAndSaveExcelColumn(_lageColIndexExcel, _regionColIndexExcel, false); Logger.Info("-- Finished Lage-Region Import"); //Merkmale -> Lage Logger.Info("-- Started DescKeyGroups Merkmal-Lage Import"); ParseAndSaveExcelColumn(_merkmaleColIndexExcel, _lageColIndexExcel, true); Logger.Info("-- Finished DescKeyGroups: Merkmal-Lage Import"); }