|
POST
|
Sorry I got ahead of you there. Because I needed to perform the field mapping on the fly i switched from using a model to using a python script. The input parameter type is going to be "File" in any case. In the script below, "infile = arcpy.GetParameterAsText(0)" is going to get the input file as a File type parameter. Then you can use the file as you please. You will see when you run this in desktop you have a file browser that you can use to browse to a file of your choice. Once you get that to run succesfully you can publish as a service. With the service you will need to get the itemID of the uploaded file and use that as an input parameter like itemID:"i83fa38d5-69e8-40c0-bd9c-30beb643e522". import arcpy, os, zipfile infile = arcpy.GetParameterAsText(0) outpath, outfileext = os.path.splitext(infile) filename = outpath.split('\\')[-1] try: # unzip file fireZip = zipfile.ZipFile(infile, 'r') fireZip.extractall(outpath) fireZip.close() shpPath = outpath + "\\" + filename + ".shp" arcpy.AddMessage("Finished unzipping file.") # Local variables: WildFire_Table_Target = "Database Connections\\SQL_DB(TEST Server).sde\\ArcSDE.dbo.WILDFIREPERIM" # Create FieldMappings object and load the target dataset fieldmappings = arcpy.FieldMappings() fieldmappings.addTable(WildFire_Table_Target) inputfields = [field.name for field in arcpy.ListFields(shpPath) if not field.required] for inputfield in inputfields: # Iterate through each FieldMap in the FieldMappings # for i in range(fieldmappings.fieldCount): fieldmap = fieldmappings.getFieldMap(i) #arcpy.AddMessage(fieldmap.getInputFieldName(0)) # If the field name from the target dataset matches to a validated input field name # if fieldmap.getInputFieldName(0) == inputfield.replace("", ""): # Add the input field to the FieldMap and replace the old FieldMap with the new # fieldmap.addInputField(shpPath, inputfield) fieldmappings.replaceFieldMap(i, fieldmap) break # Process: Append arcpy.Append_management(shpPath, WildFire_Table_Target, "NO_TEST", fieldmappings) except Exception as e: print e.message arcpy.AddError(e.message)
... View more
12-27-2012
03:59 AM
|
0
|
0
|
4214
|
|
POST
|
Hi Tom, I am a little stuck on authentication issues with the upload protion but I have some sample Siverlight code to use an uploaded file in a geoprocessing tool. You will see I have an ItemID hard coded in for now as I am not able to get the ItemID results from the file upload in silverlight. You need to pass the ItemID of the uploaded file to the geoprocessing task. I got the hang of it by using the rest endpoint to upload files and pass to the GP Service. You can use fiddler to see what is happening during each step.
Geoprocessor geoprocessorTask = new Geoprocessor("http://mygisserver/arcgis/rest/services/GPTools/WildfireUpload/GPServer/ZipImportTest");
geoprocessorTask.ExecuteCompleted += GeoprocessorTask_ExecuteCompleted;
geoprocessorTask.Failed += GeoprocessorTask_Failed;
List<GPParameter> parameters = new List<GPParameter>();
parameters.Add(new GPItemID("Input_File", "iec5a4db4-33c9-40b9-ab82-cd27ecef279f"));
//http://gis/arcgis/rest/services/GPTools/WildfireUpload/GPServer/uploads/iec5a4db4-33c9-40b9-ab82-cd27ecef279f old file link
geoprocessorTask.ExecuteAsync(parameters);
Hope this helps.
... View more
12-27-2012
03:25 AM
|
0
|
0
|
4214
|
|
POST
|
I am close to getting this using RestSharp but I am stuck with an NTLM authentication issue. I get a 401 for a response and notice in fiddler there is no authentication header. Any ideas?
string strdescr = "WillowTestfromSL";
string strRespFormat = "pjson";
RestRequest request = new RestRequest("http://myserver/arcgis/rest/services/GPTools/WildfireUpload/GPServer/uploads/upload", Method.POST);
//Get the file stream
byte[] bytes = null;
BinaryReader br = new BinaryReader(fileStream);
bytes = br.ReadBytes((int)numBytes);
//add parameters
request.AddFile("file", bytes,strFile,"application/x-zip-compressed");
request.AddParameter("desription", strdescr);
request.AddParameter("f", strRespFormat);
//calling server with restClient
RestClient restClient = new RestClient();
restClient.ExecuteAsync(request, (response) =>
{
if (response.StatusCode == HttpStatusCode.OK)
{
//upload successfull
MessageBox.Show("Upload completed succesfully...\n" + response.Content);
}
else
{
//error ocured during upload
MessageBox.Show(response.StatusCode + "\n" + response.StatusDescription);
}
});
... View more
12-21-2012
07:00 AM
|
0
|
0
|
861
|
|
POST
|
I am trying to utilize the new functionality in 10.1 that allows you to upload a file as part of a geoprocessing task. Does anytone have any examples on how to upload a file using C#. I have been hacking around with and and can't get it to work. Thanks..
... View more
12-20-2012
10:49 AM
|
0
|
3
|
2822
|
|
POST
|
Thanks for the reply. i was able to get this working by creating the mapping in a script.
Create FieldMappings object and load the target dataset
#
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(WildFire_Table_Target)
inputfields = [field.name for field in arcpy.ListFields(shpPath) if not field.required]
for inputfield in inputfields:
# Iterate through each FieldMap in the FieldMappings
#
for i in range(fieldmappings.fieldCount):
fieldmap = fieldmappings.getFieldMap(i)
#arcpy.AddMessage(fieldmap.getInputFieldName(0))
# If the field name from the target dataset matches to a validated input field name
#
if fieldmap.getInputFieldName(0) == inputfield.replace("", ""):
# Add the input field to the FieldMap and replace the old FieldMap with the new
#
fieldmap.addInputField(shpPath, inputfield)
fieldmappings.replaceFieldMap(i, fieldmap)
break
... View more
12-18-2012
07:37 AM
|
0
|
0
|
4214
|
|
POST
|
I am trying to create a service that allows a user to upload a zip file that contains a shape file, unzip it, and finally append to an existing GDB Feature Class. The fields in the shape file do not match the FC so I need to performa field mapping. However, since the input is a zip file I do not have the capabilty to set up the field mapping in the model. So when I run this it adds the elements of the shape file but all the attributes are blank because the missing mapping. Is there any way around this? [ATTACH=CONFIG]19948[/ATTACH]
... View more
12-14-2012
09:52 AM
|
0
|
25
|
9460
|
|
POST
|
Hi, Why would you need to use the Print add-in when the Print tool is the core functionality of the Viewer? Try using this tool with a sample printing service to see if it works for you: http://servicesbeta2.esri.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task Thanks for the reply. The print tool is what I am using. I call it an add-in because, "The Print Tool is a production-ready add-in that allows users of the ArcGIS Viewer for Silverlight to print their maps.". I have configured the tool to use my service as well as the sample service located at http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task with the same results.
... View more
12-12-2012
05:50 AM
|
0
|
0
|
639
|
|
POST
|
When trying to use the new (3.0) print add-in with my export web map service hosted on my local server I am having requests fail when certain layers are turned on. The layer I have issues with is a map service layer that I am hosting on the same server as the export service. Any ideas? I do not understand why it would say unable to connect to the map server as the arcgis account should have access to all the services and underlying data on that server. Error executing tool.: Layer "HOPolicies InForce": Unable to connect to map server at http://myserver/arcgis/rest/services/Entities/InForce/MapServer. Failed to execute (Export Web Map). Failed to execute (Export Web Map Task).
... View more
12-11-2012
11:32 AM
|
1
|
2
|
850
|
|
POST
|
Hi All. I am using field aliases on a layer i am hosting and the pop up for that windows displays those alias' how I expect. I have an add-in i created that performs a spatial query on that layer and returns the results back as a new layer in the map. The pop-ups and the attribute table on this new layer do not have the correct alias values. Looking at Fiddler i see the correct alias values are being sent back but for whatever reason they are not being acknowledged in my application when creating the new layer from the query results. I attached a screenshot of the configure screen for the new layer. [ATTACH=CONFIG]19825[/ATTACH] Here is a snippet of the query response from Fiddler: {"displayFieldName":"NAME","fieldAliases":{"ACCOUNT_NO":"Account #","POLICY_NO":"Policy #","NAME":"Name","RES_PREM_ADDRESS":"Address",
... View more
12-10-2012
08:01 AM
|
0
|
7
|
5589
|
|
POST
|
I also had the same issue as described in this thread. After discussing with ESRI support we determined the issue was using the port number 6080 in the connection string. Once I removed that I was able to publish without any issue. Connection details are documenting here in the 10.1 Help Guide.
... View more
11-29-2012
10:36 AM
|
0
|
0
|
3248
|
|
POST
|
I had the same issue on a brand new server configuration. I wiped everything out and tried again following the exact same steps without any further issues. Very strange..
... View more
11-29-2012
10:27 AM
|
0
|
0
|
1214
|
|
POST
|
Patrick- Have you had a chance to see if the slowness issues have been resolved with SP1?
... View more
11-29-2012
09:58 AM
|
0
|
0
|
3279
|
|
POST
|
There appears to be an issue with the Surface Profile sample. I am getting a 404 not found in fiddler when submitting a request using the sample. GET http://sampleserver2b.arcgisonline.com/arcgisoutput/_ags_profile_jf4fa67727cd84d4facc24ec19d9b3393_1.png
... View more
11-20-2012
04:41 AM
|
0
|
0
|
1186
|
|
POST
|
I was thinking it would be nice if the viewer had the ability to add a favorite icon to the website and the ability to change the title as well. I am using the following lines in the index.htm page to do so. It would just be nicer to be able to do this in the viewer.
<head>
<link rel="SHORTCUT ICON" href="favicon.ico"/>
<title>Test Map</title>
[ATTACH=CONFIG]18615[/ATTACH]
... View more
10-22-2012
06:16 AM
|
0
|
0
|
1630
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-21-2026 06:15 AM | |
| 4 | 03-12-2025 11:01 AM | |
| 3 | 01-08-2025 09:26 AM | |
| 1 | 01-08-2025 07:19 AM | |
| 1 | 12-06-2024 04:52 AM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|