Dim pValue As IRasterValue Dim pRasterDataset As IRasterDataset3 Dim pWorkspaceFactory As IWorkspaceFactory Dim pWorkspace As IWorkspace Dim pSaveAs As ISaveAs Dim pPropSet As IPropertySet = New PropertySetClass() With pPropSet .SetProperty("Server", My.Settings.Server) .SetProperty("Instance", My.Settings.Instance) .SetProperty("Database", My.Settings.Database) .SetProperty("AUTHENTICATION_MODE", My.Settings.AUTHENTICATION_MODE) .SetProperty("USER", My.Settings.USER) .SetProperty("PASSWORD", My.Settings.PASSWORD) .SetProperty("version", "sde.DEFAULT") End With Dim pSDEWorkspace As IWorkspace Dim pSDEWorkspaceFactory As New SdeWorkspaceFactory pSDEWorkspace = pSDEWorkspaceFactory.Open(pPropSet, 0) Dim pFeatureWorkspace As IFeatureWorkspace = pSDEWorkspace Dim pFeatureClass As IFeatureClass = pFeatureWorkspace.OpenFeatureClass(My.Settings.FCName) Dim pFeatcursor As IFeatureCursor = pFeatureClass.Search(Nothing, True) Dim pfeature As IFeature = pFeatcursor.NextFeature Dim pFlds As IFields = pFeatureClass.Fields Dim rasterfieldidx = FindCheckField(My.Settings.RasterFieldName, esriFieldType.esriFieldTypeRaster, pFlds) Dim datefieldidx = FindCheckField(My.Settings.DateField, esriFieldType.esriFieldTypeDate, pFlds) Dim photofileidx = FindCheckField(My.Settings.RasterPhotoLink, esriFieldType.esriFieldTypeString, pFlds) Dim globalididx = FindCheckField("GlobalID", esriFieldType.esriFieldTypeGlobalID, pFlds) Dim fcount As Integer = 0 While Not pfeature Is Nothing Try 'Export Raster If Not pfeature.Value(rasterfieldidx) Is System.DBNull.Value Then pValue = pfeature.Value(rasterfieldidx) pRasterDataset = pValue.RasterDataset pWorkspaceFactory = New RasterWorkspaceFactoryClass pWorkspace = pWorkspaceFactory.OpenFromFile(My.Settings.DestDir, 0) pSaveAs = pRasterDataset Dim filename As String = My.Settings.DestDir & "\" + Mid(pfeature.Value(globalididx), 2, Len(pfeature.Value(globalididx)) - 2) + ".jpg" If pSaveAs.CanSaveAs("JPEG") And System.IO.File.Exists(filename) = False Then pSaveAs.SaveAs(filename, pWorkspace, "JPEG") If IO.File.Exists(filename) Then 'Add filename pfeature.Value(photofileidx) = IO.Path.GetFileName(filename) 'Clear Raster Field pfeature.Value(rasterfieldidx) = System.DBNull.Value pfeature.Store() fcount += 1 End If ElseIf System.IO.File.Exists(filename) Then pfeature.Value(rasterfieldidx) = System.DBNull.Value pfeature.Store() End If End If Catch ex1 As System.InvalidCastException m_evlog.WriteEntry(ex1.Message + " CONTINUING") Catch ex As Exception m_evlog.WriteEntry("Exception: " & ex.Message) End Try pfeature = pFeatcursor.NextFeature End While
As far as I know the web api's can't handle raster fields. (please someone tell me I'm wrong)... and yes attachments might answer our problem.
I've attached some partial code on how to export to jpg. I store the resulting jpg's name in a field but you could construct that on the fly. I also empty the raster field. And I apologize for my messy code... There are references in that code to functions that aren't in there.
There's probably more in there than you need.
We've got quite a few mobile projects.... some do overlap, using the same service. Some apps use multiple services.Dim pValue As IRasterValue Dim pRasterDataset As IRasterDataset3 Dim pWorkspaceFactory As IWorkspaceFactory Dim pWorkspace As IWorkspace Dim pSaveAs As ISaveAs Dim pPropSet As IPropertySet = New PropertySetClass() With pPropSet .SetProperty("Server", My.Settings.Server) .SetProperty("Instance", My.Settings.Instance) .SetProperty("Database", My.Settings.Database) .SetProperty("AUTHENTICATION_MODE", My.Settings.AUTHENTICATION_MODE) .SetProperty("USER", My.Settings.USER) .SetProperty("PASSWORD", My.Settings.PASSWORD) .SetProperty("version", "sde.DEFAULT") End With Dim pSDEWorkspace As IWorkspace Dim pSDEWorkspaceFactory As New SdeWorkspaceFactory pSDEWorkspace = pSDEWorkspaceFactory.Open(pPropSet, 0) Dim pFeatureWorkspace As IFeatureWorkspace = pSDEWorkspace Dim pFeatureClass As IFeatureClass = pFeatureWorkspace.OpenFeatureClass(My.Settings.FCName) Dim pFeatcursor As IFeatureCursor = pFeatureClass.Search(Nothing, True) Dim pfeature As IFeature = pFeatcursor.NextFeature Dim pFlds As IFields = pFeatureClass.Fields Dim rasterfieldidx = FindCheckField(My.Settings.RasterFieldName, esriFieldType.esriFieldTypeRaster, pFlds) Dim datefieldidx = FindCheckField(My.Settings.DateField, esriFieldType.esriFieldTypeDate, pFlds) Dim photofileidx = FindCheckField(My.Settings.RasterPhotoLink, esriFieldType.esriFieldTypeString, pFlds) Dim globalididx = FindCheckField("GlobalID", esriFieldType.esriFieldTypeGlobalID, pFlds) Dim fcount As Integer = 0 While Not pfeature Is Nothing Try 'Export Raster If Not pfeature.Value(rasterfieldidx) Is System.DBNull.Value Then pValue = pfeature.Value(rasterfieldidx) pRasterDataset = pValue.RasterDataset pWorkspaceFactory = New RasterWorkspaceFactoryClass pWorkspace = pWorkspaceFactory.OpenFromFile(My.Settings.DestDir, 0) pSaveAs = pRasterDataset Dim filename As String = My.Settings.DestDir & "\" + Mid(pfeature.Value(globalididx), 2, Len(pfeature.Value(globalididx)) - 2) + ".jpg" If pSaveAs.CanSaveAs("JPEG") And System.IO.File.Exists(filename) = False Then pSaveAs.SaveAs(filename, pWorkspace, "JPEG") If IO.File.Exists(filename) Then 'Add filename pfeature.Value(photofileidx) = IO.Path.GetFileName(filename) 'Clear Raster Field pfeature.Value(rasterfieldidx) = System.DBNull.Value pfeature.Store() fcount += 1 End If ElseIf System.IO.File.Exists(filename) Then pfeature.Value(rasterfieldidx) = System.DBNull.Value pfeature.Store() End If End If Catch ex1 As System.InvalidCastException m_evlog.WriteEntry(ex1.Message + " CONTINUING") Catch ex As Exception m_evlog.WriteEntry("Exception: " & ex.Message) End Try pfeature = pFeatcursor.NextFeature End While
I have now reached 2400+ points in my feature class and I am experiencing this problem too. I noticed that when my Laptop is rendering 1000+ points it will crash giving the same error you get.
But when my Tablet PC was rendering those same 1000+ points it will still ok.
My laptop is running XP with 1GB of ram.
My tablet pc is running Win 7 with 2GB of ram.
I did my performance tests last week, and did two tests. The first 1000+ points having both Laptop and Tablet PC running and collecting points, the laptop did crash giving the same error. While the Tablet PC continued to collect points.
I did the second test, which is in addition to the already existing 1000+ points in the feature class. The test was the same setup as before, and once the Laptop created around 700+ points, it crashed. The Tablet PC created roughly 300+ points when the laptop crashed, and the tablet pc was still running fine.
I still want to run some more performance tests but, I am running low on time.
I am also using the ArcGIS Mobile WPF application, but I have coded my own data collection and synchronization with the server code. I have an auto collect button, that will collect a point on the map every 3-4 seconds and will sync each point after the point is made. The tablet pc has a slower CPU and wireless internet connection and it takes roughly 6-8 seconds to make a point.
As the number of features increases in the featureclass, the tablet pc becomes slower to create points and sync, roughly 10-11 seconds once there are over 1000+ points in the featureclass. However, the laptop with a faster CPU and LAN connection to the network was able to maintain a stable 3-4 seconds point creation with sync.
I am not sure if it is the CPU or internet connection that causes the tablet pc to slow down in the data collection process with sync. I am not sure why the laptop crashes around the 1000+ points mark, as both Tablet PC and Laptop are running and collecting points.
* Yes my featureclass has a Raster field for photos and very few points actually contain a raster images with the point. When there is a photo taken, they are at a high resolution, 1600x1200.
If time prevails, I will try to determine if it is a CPU + Ram issue or a Internet Connection speed issue that causes this out of memory error.
I am not sure why you are losing data when your application crashes, it shouldn't be a corruption issue. As far as I understand, if your project file gets corrupted you are likely to lose all data point collected by that one particular nomad. But if a normal error occurs, the data should be ok, and just manually post updates.
In addition, disable team tracking may help with you sync issue. I noticed that my application does not like Tracking to be turned on when auto collection mode it turned on. This causes massive sync issues.
So if you turn off tracking, and enable the sync to occur when data changes, your problem should be solved in terms of not losing data when ArcGIS Mobile crashes.
Sorry for the long post.