Select to view content in your preferred language

How do you automatically copy collected data to another database?

1349
7
Jump to solution
08-26-2014 10:48 PM
GISSupport3
Frequent Contributor

G'day All!

No response in the ArcCollector place and probably more relevant to here anyways.

What hooks / notifications are there to use after a REST service has updated a feature class?

Once data has come 'in' from Collector, we wish to add a notification to a different system.

Database triggers and scheduled tasks are frowned upon.

Any suggestions greatly appreciated.

Thanks

0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

You may be able to fire the python script using a database trigger, but I've never attempted this before.

View solution in original post

0 Kudos
7 Replies
JakeSkinner
Esri Esteemed Contributor

Hello,

You could create a replica between your geodatabases.  However, synchronizing the changes would be a manual process w/o creating a scheduled task.

GISSupport3
Frequent Contributor

G'day Jake

I like the idea and not sure it will work in this situation? Some more details from me may help.

A field user submits a situation report or a weather report or something with ArcCollector.

This data lands in HQ in our field geodatabase.

We then wish to automatically populate an event log in our operational system (non spatial) database.

HH:MM: Joe Blogs: New weather report: Temp: 39, Humidity 22 etc etc

(To add to the mix, the event log also requires an incident name and there is NO attribute in ArcCollector to say what is the relevant incident(s). We would prefer users NOT to type this in. There will be multiple collectors at multiple incidents at any one time. Some spatial analysis is also required as a part of the automation)

Maybe can't avoid trigger / scheduled task?

Thanks again

0 Kudos
JakeSkinner
Esri Esteemed Contributor

I think Python would be best for this situation.  You can query the feature service, and then update the database table.  Here is an example on how to query an ArcGIS Online hosted feature service:

import urllib, urllib2, json, smtplib

username = "gis"

password = "p@ssword"

#generate token

tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken'

params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'http://www.arcgis.com'}

req = urllib2.Request(tokenURL, urllib.urlencode(params))

response = urllib2.urlopen(req)

data = json.load(response)

token = data['token']

#query service to retrieve how many are of type 'Single Dwelling Houses'

damageAssessmentURL = 'http://services.arcgis.com/FBBJUji5ArUSDM/arcgis/rest/services/Damage_Assessment_Arlington/FeatureSe...'

where = "PropertyType = 'Single Dwelling Houses'"

params = {'f': 'pjson', 'where': where, 'returnCountOnly': 'true', 'token': token}

req = urllib2.Request(damageAssessmentURL, urllib.urlencode(params))

response = urllib2.urlopen(req)

data = json.load(response)

print data['count']

I would recommend a scheduled task to run the script at a given interval to update the table.

0 Kudos
GISSupport3
Frequent Contributor

G'day Jake

Sounds good.

Just to confirm, there is no (simple / efficient) way to fire the python from a notification from the server; ie running as a listener rather than scheduled task?

Thanks

0 Kudos
JakeSkinner
Esri Esteemed Contributor

You may be able to fire the python script using a database trigger, but I've never attempted this before.

0 Kudos
GISSupport3
Frequent Contributor

Ok. Not sure what way we'll go and time will tell.

Thanks again

0 Kudos
JordanBaumgardner
Frequent Contributor

It's still a trigger, but you could easily call a web service, from there you have all options ava - ArcObjects, direct db interaction, ect.

How to invoke a Web Service from a Stored Procedure - CodeProject