Exception from a shapefile whose .dbf contains a "Date" field

3281
7
Jump to solution
06-13-2015 12:05 PM
WlodzimierzSzafran
New Contributor

Hi,

I just encountered strange behaviour when trying to use a ShapefileTable from a shapefile that has at least one field of type "Date" among the attributes in its .dbf file. Any attempt to either get a count of the features or to iterate over the features ends in an exception:

"The added or subtracted value results in an un-representable DateTime. Parameter name: t"

Steps to reproduce:

Use any shapefile with at least one attribute of type "Date", with actual dates in the data, and then:

var shapefileTable = await ShapefileTable.OpenAsync(fileName);

var features = await shapefileTable.QueryAsync(new QueryFilter() { WhereClause = "1=1" });

if (features == null || features.Count() == 0)

{

    // e.g. throw an exception

}

The relevant stack trace:

   at System.DateTime.op_Addition(DateTime d, TimeSpan t)

   at Esri.ArcGISRuntime.Internal.DateUtils.FromMillisecondsSinceEpoch(Int64 milliSeconds)

   at Esri.ArcGISRuntime.Data.ArcGISFeatureTable.RowEnumerator.<System.Collections.Generic.IEnumerable<Esri.ArcGISRuntime.Data.GeodatabaseFeature>.GetEnumerator>d__48.MoveNext()

   at Esri.ArcGISRuntime.Data.ArcGISFeatureTable.RowEnumerator.<System.Collections.Generic.IEnumerable<Esri.ArcGISRuntime.Data.Feature>.GetEnumerator>d__4e.MoveNext()

   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)

I would appreciate if this was acknowledged as an issue and fixed as soon as possible.

Thanks, regards.

0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor

Hi,

Good news: we have recently addressed this issue and I have verified against the latest build of the forthcoming 10.2.6 SDK. The problem was apparently null date values in the Shapefile.

Your example code now successfully reports the feature count (I added the MessageBox):

var shapefileTable = await ShapefileTable.OpenAsync(fileName);
var features = await shapefileTable.QueryAsync(new QueryFilter() { WhereClause = "1=1" });
if (features == null || features.Count() == 0)
{                                                             
                // e.g. throw an exception
}
else
                MessageBox.Show(features.Count().ToString());

Cheers

Mike

View solution in original post

0 Kudos
7 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

Please can you upload a Shapefile we can test with?

Cheers

Mike

0 Kudos
WlodzimierzSzafran
New Contributor

Hi Michael,

Could this be done outside of the forum? I'd like to pass a problematic file to you for testing but certainly wouldn't like to share it publicly. For example, I could give you a Dropbox link.

Thanks, regards.

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

Absolutely - feel free to email me a link to download: mbranscomb@esri.com.

Cheers

Mike

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

Good news: we have recently addressed this issue and I have verified against the latest build of the forthcoming 10.2.6 SDK. The problem was apparently null date values in the Shapefile.

Your example code now successfully reports the feature count (I added the MessageBox):

var shapefileTable = await ShapefileTable.OpenAsync(fileName);
var features = await shapefileTable.QueryAsync(new QueryFilter() { WhereClause = "1=1" });
if (features == null || features.Count() == 0)
{                                                             
                // e.g. throw an exception
}
else
                MessageBox.Show(features.Count().ToString());

Cheers

Mike

0 Kudos
WlodzimierzSzafran
New Contributor

Hi Mike,

good to hear that the problem has been addressed, thanks for your involvement.

Looking forward to the 10.2.6 release.

Regards.

0 Kudos
TonyGeorges1
New Contributor III

Hi Mike,

We are experiencing the same problem when loading an SQLite geodatabase (saved from ArcGIS Online) into a FeatureTable Source.

The feature table contains a Date Range domain. Do you have any idea about this problem ?

The stack trace :

Message : TimeSpan does not accept floating point Not-a-Number values.. Source : mscorlib. StackTrace :

   at System.TimeSpan.Interval(Double value, Int32 scale)

   at Esri.ArcGISRuntime.Internal.DateUtils.FromMillisecondsSinceEpoch(Double milliSeconds)

   at RuntimeCoreNet.BinaryReaderExtensions.ReadRowVariant(BinaryReader r, RowValueType type)

   at RuntimeCoreNet.BinaryReaderExtensions.ReadRowVariant(BinaryReader r)

   at RuntimeCoreNet.CoreFeatureSource.GetDomainInfo(String domainName)

   at Esri.ArcGISRuntime.Data.FeatureTable.SetSource(CoreFeatureSource source)

   at Esri.ArcGISRuntime.Data.GeodatabaseFeatureTable..ctor(CoreFeatureSource source, Geodatabase owner)

   at Esri.ArcGISRuntime.Data.Geodatabase.<get_FeatureTables>d__0.MoveNext()

   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)

   at SOMaps.Manager.Offline.OfflineDataManager.<HasOfflineDataForLayerAsync>d__83.MoveNext()

The Code: 

Geodatabase gdb = await Geodatabase.OpenAsync(path);

gdb.FeatureTables.Count()

I can share you the sqlite geodatabase if you need,

Thank you for your help,

Tony

0 Kudos
AnttiKajanus1
Regular Contributor II

Hi Tony,

Could you provide simple reproducer for this issue so I can have a look what's going on?

cheers

0 Kudos