GP tool dialog won't go away or pass messages

429
2
Jump to solution
03-05-2012 08:03 PM
MarkPeacey
New Contributor III
We've got some GP tools in an MXD which we publish and then use in the ArcGIS Viewer for Silverlight. When we execute the script it works fine but after having done the processing the dialog box sits there with the "Getting results..." message and doesn't finish, stop or disappear. How do we clear the processing thread\SOC or whatever and have the dialog box work as it should I guess.

Also, is there a way of passing messages from a Script to a user in the ArcGIS Viewer using a GP tool? I've tried AddMessage in the script but it doesn't show up. The whole things works fine in the MXD but I'd like to add some user feedback in the Viewer so the user knows it has done what it should have.

Thanks in advance.

# Import arcpy module import arcpy  arcpy.env.Overwriteoutput = True  # Local variables: Stoat_Trap_Input = arcpy.GetParameterAsText(0) Stoat_Trap_Records = "Stoat Trap Records" stifl = "in_memory\\stifl"  try:          arcpy.MakeFeatureLayer_management(Stoat_Trap_Input, stifl, "Trap1 <>'Unchecked' OR Trap2 <>'Unchecked'")     featurecount = arcpy.GetCount_management(stifl)          print featurecount      if not featurecount == 0:          arcpy.AddMessage("Input layer " + Stoat_Trap_Input + " has " + str(featurecount) + " new\updated records.")         arcpy.AddMessage("Adding " + str(featurecount) + " new\updated records to the main database.")                  arcpy.Append_management("in_memory\\stifl", Stoat_Trap_Records, "NO_TEST")         arcpy.AddMessage(str(featurecount) + " new\updated records successfully added.")          arcpy.CalculateField_management(stifl, "Trap1", "\"Unchecked\"", "PYTHON_9.3", "")          arcpy.CalculateField_management(stifl, "Trap2", "\"Unchecked\"", "PYTHON_9.3", "")                  arcpy.RefreshActiveView()              else:         arcpy.AddMessage("Input layer " + Stoat_Trap_Input + " has no new updates. Records must be added\updated before they require processing.")          except:          msgs = arcpy.GetMessages(2)     arcpy.AddError(msgs)     arcpy.AddMessage(msgs)     print msgs  del arcpy
0 Kudos
1 Solution

Accepted Solutions
GerardoGarza
New Contributor III
Mark,
The viewer geoprocessing tool is probably hanging because it is not receiving an output object from the server.
Once an output is set in the python script, the tool, and the model, it should show up in the viewer tool setup.
Even adding a message string saying "Processing Complete" is enough for the viewer tool.
For more info, see the document on Geoprocessing Input/Output Data Types.
Hope that helps,
GG

View solution in original post

0 Kudos
2 Replies
GerardoGarza
New Contributor III
Mark,
The viewer geoprocessing tool is probably hanging because it is not receiving an output object from the server.
Once an output is set in the python script, the tool, and the model, it should show up in the viewer tool setup.
Even adding a message string saying "Processing Complete" is enough for the viewer tool.
For more info, see the document on Geoprocessing Input/Output Data Types.
Hope that helps,
GG
0 Kudos
MarkPeacey
New Contributor III
Thanks Gerardo. Our local support vendor suggested the same and I've now implemented an output parameter for messaging and to indicate it has finished. Only problem is running the GP tool more than once just shows up the same message. Our IE settings are set to cache the json response so it gives the same response when run again in the same session. Apparently in the Silverlight API you can disable client caching. Not so in the prebuilt ArcGIS Viewer for Silverlight.
0 Kudos