Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DataPlugins/DataPluginImporter.cs =================================================================== diff -u -r2168 -r2204 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DataPlugins/DataPluginImporter.cs (.../DataPluginImporter.cs) (revision 2168) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DataPlugins/DataPluginImporter.cs (.../DataPluginImporter.cs) (revision 2204) @@ -1054,6 +1054,11 @@ importer.Import(progress); exceptions.AddRange(importer.ImportErrors); + foreach (var importerMessage in importer.ImproperAttributeMessages) + { + var lm = new LogMessage(LogMessageType.Error, this, importerMessage); + importLogMessages.Add(lm); + } } using (var sw = new StreamWriter(importErrorLogFile, false)) @@ -1066,7 +1071,7 @@ DateTime.Now.ToShortDateString(), error.GetType().Name, error.Message); var lm = new LogMessage(LogMessageType.Error, this, error.Message); importLogMessages.Add(lm); - } + } } } Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Importers/LocationPropertyImporter.cs =================================================================== diff -u -r2089 -r2204 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Importers/LocationPropertyImporter.cs (.../LocationPropertyImporter.cs) (revision 2089) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Importers/LocationPropertyImporter.cs (.../LocationPropertyImporter.cs) (revision 2204) @@ -46,7 +46,7 @@ private readonly IDictionary> filesToImportFrom; private readonly PolygonAttributeImporter polygonAttributeImporter; private readonly LineAttributeImporter lineAttributeImporter; - + private List improperAttributeMessages = new List(); private IEnumerable targets; public LocationPropertyImporter() @@ -62,17 +62,30 @@ this.lineAttributeImporter = new LineAttributeImporter(); } + public List ImproperAttributeMessages + { + get { return improperAttributeMessages; } + } + public LocationPropertyImporter(string dataLocation, IEnumerable dataAttributes) : this() { this.DataFileLocation = dataLocation; - + improperAttributeMessages.Clear(); // Register configured property attributes foreach (var dataAttribute in dataAttributes) { if (LocationShapeFileAttributeMap.IsPropertyAttribute(dataAttribute.AttributeId)) RegisterAttributeMapping(dataAttribute.AttributeId, dataAttribute.AttributeName, dataAttribute.DataSource); } + if (improperAttributeMessages.Count > 0) + { + var message = Environment.NewLine + "The following attribute id's are supported:" + Environment.NewLine + + string.Join(", ", LocationShapeFileAttributeMap.AttributePropertyMap.Keys.OrderBy(k => k).ToArray()); + + message += Environment.NewLine + "Please change the id in the shape file or remove the shape for this attribute from the defx."; + improperAttributeMessages.Add(message); + } // Should throw an exception when more then one crosssection is defined.. RegisterCrossSectionAttribute(dataAttributes); } @@ -173,42 +186,38 @@ { string message = string.Format("The attribute id '{0}' is not supported by this importer.", attributeId); - - message += Environment.NewLine + Environment.NewLine + "The following attribute id's are supported:" + Environment.NewLine + - string.Join(", ", LocationShapeFileAttributeMap.AttributePropertyMap.Keys.OrderBy(k => k).ToArray()); - - message += Environment.NewLine + Environment.NewLine + "Please change the id in the file."; - - throw new NotSupportedException(message); + improperAttributeMessages.Add(message); } + else + { + LocationAttributeMapping mapping = LocationShapeFileAttributeMap.GetAttributeMapping(attributeId); + string attrName = string.IsNullOrEmpty(customAttributeName) || customAttributeName.Trim() == "" + ? mapping.Name // return the default shape file colum name + : customAttributeName; - LocationAttributeMapping mapping = LocationShapeFileAttributeMap.GetAttributeMapping(attributeId); - string attrName = string.IsNullOrEmpty(customAttributeName) || customAttributeName.Trim() == "" - ? mapping.Name // return the default shape file colum name - : customAttributeName; + if (!IsValidString(dataFileName)) // not a valid file location? use the default file + dataFileName = mapping.File; - if (!IsValidString(dataFileName)) // not a valid file location? use the default file - dataFileName = mapping.File; + Action action = mapping.Action; - Action action = mapping.Action; + // Build a map to data (shape) files and attributes contained in the dbf file + // if a file is already added to the map a new attribute will be added + // to support the concept that multiple attributes can be contained in a single (shape) file + // ie. { somedatashapefile.shp, { TRAFFLOAD, PENLENGTH, .. } } - // Build a map to data (shape) files and attributes contained in the dbf file - // if a file is already added to the map a new attribute will be added - // to support the concept that multiple attributes can be contained in a single (shape) file - // ie. { somedatashapefile.shp, { TRAFFLOAD, PENLENGTH, .. } } + ShapeFileLocation file = GetFile(dataFileName); - ShapeFileLocation file = GetFile(dataFileName); + string key = file.FullPath; - string key = file.FullPath; + if (!this.filesToImportFrom.ContainsKey(key)) + this.filesToImportFrom.Add(key, new List()); - if (!this.filesToImportFrom.ContainsKey(key)) - this.filesToImportFrom.Add(key, new List()); - - this.filesToImportFrom[key].Add(new LocationAttributeMapping - { - Action = action, - Name = attrName - }); + this.filesToImportFrom[key].Add(new LocationAttributeMapping + { + Action = action, + Name = attrName + }); + } } // used for testing purposes...