not able to upload shapefile in arcgis 3.10 with custom built gp service with error :500:“Error performing...

Are Wave equations equivalent to Maxwell equations in free space?

Was it really inappropriate to write a pull request for the company I interviewed with?

Can inspiration allow the Rogue to make a Sneak Attack?

Using the imperfect indicative vs. subjunctive with si

Why do we call complex numbers “numbers” but we don’t consider 2 vectors numbers?

Python 3.6+ function to ask for a multiple-choice answer

Problems with rounding giving too many digits

Did Amazon pay $0 in taxes last year?

How spaceships determine each other's mass in space?

Sundering Titan and basic normal lands and snow lands

What is "desert glass" and what does it do to the PCs?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

Quitting employee has privileged access to critical information

How do we objectively assess if a dialogue sounds unnatural or cringy?

Ultrafilters as a double dual

Does the US political system, in principle, allow for a no-party system?

Custom javascript not working

Are there other characters in the Star Wars universe who had damaged bodies and needed to wear an outfit like Darth Vader?

What is a term for a function that when called repeatedly, has the same effect as calling once?

Is it a Cyclops number? "Nobody" knows!

Too soon for a plot twist?

What is the meaning of option 'by' in TikZ Intersections

Why is there an extra space when I type "ls" on the Desktop?

Why won't the strings command stop?



not able to upload shapefile in arcgis 3.10 with custom built gp service with error :500:“Error performing upload operation”


Custom ArcGIS Server Web Service can't find Esri assembliesWFS service Server Error in '/ArcGIS/services' ApplicationIs the PostGIS Shapefile Import Manager able to upload to phpmyadmin or only pgadmin III?ArcGIS Server geoprocessing service examples for shapefile data exportError code 500 at REST Endpoint of published geoprocessing service perhaps due to output parameter type?Publishing ArcGIS geoprocessing service - upload custom python modules?Not able to overwrite/delete an existing Service in ArcGIS Server?Adding custom error in published geoprocessing service using ArcPy?How to upload a shapefile using WFS service?Creating ArcGIS Service (FeatureAccess) with dynamic datasource?













0















var submitcheck;
define([
'dojo/_base/declare',
'dojo/_base/lang',
'dojo/_base/array',
'dojo/_base/Deferred',
"dojo/number",
"esri/sniff",
"esri/config",
'esri/request',
'esri/geometry/Extent',
'esri/toolbars/draw',
'esri/geometry/Circle',
'esri/geometry/Point',
'esri/units',
'esri/graphic',
'esri/tasks/query',
'esri/tasks/QueryTask',
"esri/tasks/RelationshipQuery",
"esri/geometry/scaleUtils",
"esri/layers/FeatureLayer",
"esri/renderers/SimpleRenderer",
"dojo/promise/all",
'esri/SpatialReference',
'esri/dijit/InfoWindowLite',
'esri/InfoTemplate',



 'dojo/request/xhr',
'dojo/on',
'dojo/dom',
'dojo/topic',
'dojo/dom-construct',

"esri/geometry/webMercatorUtils",

"dojo/colors",
"dojo/fx/easing",
"dojox/charting/Chart",
"dojox/charting/axis2d/Default",
"dojox/charting/plot2d/Grid",
"dojox/charting/plot2d/Areas",
"dojox/charting/plot2d/StackedAreas",
"dojox/charting/action2d/MouseIndicator",
"dojox/charting/action2d/TouchIndicator",
"dojox/charting/themes/ThreeD",
"dojox/charting/themes/Wetland",
'dijit/form/Select',
'dijit/form/Button',
'dijit/form/DropDownButton',
'dijit/form/ComboBox',
'dijit/form/ValidationTextBox',
'esri/geometry/geodesicUtils',

'dijit/Dialog',
'dijit/TooltipDialog',
'dojox/grid/DataGrid',
"esri/dijit/Measurement",

'dijit/layout/ContentPane',
'dijit/layout/BorderContainer',
'dijit/layout/TabContainer',
'dojo/data/ItemFileWriteStore',
'esri/Color',
'esri/tasks/LengthsParameters',
'esri/tasks/GeometryService',
'esri/tasks/Geoprocessor',
'esri/tasks/FeatureSet',
'esri/tasks/LinearUnit',

'dijit/registry',
'dijit/popup',
'dojo/store/Memory',
'dojo/data/ObjectStore',
"esri/symbols/PictureMarkerSymbol",
"esri/symbols/SimpleFillSymbol",
'esri/symbols/SimpleLineSymbol',
'esri/symbols/SimpleMarkerSymbol',
'esri/symbols/CartographicLineSymbol',

'app/mapconfig',
'app/utils',
'app/saploadquery',
'app/messagebox',
'dijit/popup',
"dojo/json",
"dojo/parser"

],
function (declare, lang, arrayUtils, Deferred, number, sniff, esriConfig, request,
Extent, Draw, Circle, Point, Units, Graphic, Query, QueryTask, RelationshipQuery, scaleUtils, FeatureLayer, SimpleRenderer, Promise, SpatialReference, InfoWindowLite, InfoTemplate,
Xhr, On, dom, Topic, domConstruct, webMercatorUtils,
colors, easing, Chart, Default, Grid, Areas, StackedAreas, MouseIndicator, TouchIndicator, ThreeD, Wetland,
Select, Button, DropDownButton, ComboBox, ValidationTextBox, GeodesicUtils,
Dialog, TooltipDialog, DataGrid, Measurement,
ContentPane, BorderContainer, TabContainer,
ItemFileWriteStore, Color, LengthsParameters, GeometryService, Geoprocessor, FeatureSet, LinearUnit,
Registry, popup, Memory, ObjectStore, PictureMarkerSymbol, SimpleFillSymbol, SimpleLineSymbol, SimpleMarkerSymbol, CartographicLineSymbol,
MapConfig, Utils, SapLoadQuery, mesgObj, popup, JSON, parser) {

var mapConfig = new MapConfig();
var cemUtils = new Utils();
var map = null;
var thisItem = null;

return declare(null, {

whoami: 'ADDSHAPEFILE',
map: null,
uname: null,
newtooltipdialog: null,

result_test: null,
/* Constructor */
constructor: function (map) {

console.log("Loaded " + this.whoami);
_map = map;
this.map = map;
// thisItem = this;
// this.submitcheck();

},
submitcheck: function (event) {
console.log();
var a = dojo.byId("_form").value;
// alert();


},


displayaddFileDialog: function (anchorID) {

var contentpanenew = new ContentPane({
id: 'contentpanenew',
selected: 'true',
content: '<div id="buttons" style="background-color:#E8E8E8;">Select files to upload by clicking on the Browse button <br/>'
+ '(Supported extension types: .zip)<br/><br/></div>'
+ '<form id="_form" data-dojo-attach-point="_form" name="_form" method="post" enctype="multipart/form-data" >'
+ '<input type = "file" id="uploadFileInput" data-dojo-attach-point="uploadFileInput" accept=".zip" name = "_file" style="width: 190px; opacity: 0.75; padding: 5px;"></input>'
+ '<br/>'
+ '<button id="submitButton" name="submitButton" type="submit" data-dojo-type="dijit/form/Button" style="margin-top: 10px;"> Submit </button>'
+ '<button id="closeUploadDialog" name="closeUploadDialog" data-dojo-type="dijit/form/Button" style="margin-top: 10px;"> Close </button>'

+ '</form><br/><br/>'

});

// onsubmit = "try: submitcheck()" target="_iframe"
var newtooltipdialog = new TooltipDialog({ content: contentpanenew });
newtooltipdialog.startup();

On(dom.byId(anchorID), 'click', function () {
if (dijit.byId(anchorID).get('disabled') == false) {
popup.open({ popup: newtooltipdialog,
around: dom.byId(anchorID),
orient: ["below-centered"]
});
}
}); // end of On
// function submitcheck(event) {
// alert();
// }


Registry.byId('submitButton').on('click', function (e) {
// On(dom.byId("uploadForm"), "change", function (e) {
parser.parse();

var portalUrl = "https://www.arcgis.com";

//esriConfig.defaults.io.proxyUrl = "/proxy/";
// var a = document.getElementById('inFile').files[0];
// var name_element = _file.value.toLowerCase();
var name_element = dojo.byId("uploadFileInput").value;
//alert(name_element);

if (sniff("ie")) { //filename is full path in IE so extract the file name
var arr = name_element.split("\");
name_element = arr[arr.length - 1];
}
if (name_element.indexOf(".zip") !== -1) {//is file a zip - if not notify user
// alert("this is a zip file");
generateFeatureCollection(name_element);
}
else {
alert("this is not a zip folder");
}

function generateFeatureCollection(name_element) {
var namefeat = name_element.split(".");
//Chrome and IE add c:fakepath to the value - we need to remove it
//See this link for more info: http://davidwalsh.name/fakepath
namefeat = namefeat[0].replace("c:\fakepath\", "");
// namefeat = namefeat[0];
// dom.byId('upload-status').innerHTML = '<b>Loading… </b>' + name;

//Define the input params for generate see the rest doc for details
//http://www.arcgis.com/apidocs/rest/index.html?generate.html
var params = {
'name': namefeat,
'targetSR': _map.spatialReference,
'maxRecordCount': 100000,
'enforceInputFileSizeLimit': true,
'enforceOutputJsonSizeLimit': true
};

//generalize features for display Here we generalize at 1:40,000 which is approx 10 meters
//This should work well when using web mercator.
var extent = scaleUtils.getExtentForScale(_map, 40000);
var resolution = extent.getWidth() / _map.width;
params.generalize = true;
params.maxAllowableOffset = resolution;
params.reducePrecision = true;
params.numberOfDigitsAfterDecimal = 0;

var myContent = {
'filetype': 'shapefile',
'publishParameters': JSON.stringify(params),
'f': 'json',
'callback.html': 'textarea'
};
var a = dom.byId('_form');
var b = document.getElementById("uploadFileInput");
var c = dojo.byId("uploadFileInput");


// var uploadUrl = 'http://umario.cem-macau.com:6080/arcgis/rest/services/shapefiletolayernew/GPServer/uploads/upload';
// var uploadRequest = request({
// url: this.uploadUrl,
// form: dom.byId("_form"),
// handleAs: "json",
// content: myContent
// }, {
// useProxy: true,
// usePost: true
// });
// uploadRequest.then(lang.hitch(this, this.handleFileLoad), lang.hitch(this, this.handleFileLoadError));
// showProgressDialog("Uploading Files.......", true);



                       //use the rest generate operation to generate a feature collection from the zipped shapefile
request({
url: 'http://umario.cem-macau.com:6080/arcgis/rest/services/shapefiletolayernew/GPServer/uploads/upload',
// url: portalUrl + '/sharing/rest/content/features/generate',
content: myContent,
form: dojo.byId('_form'),
handleAs: 'json',
useProxy: true,
usePost: true,
load: lang.hitch(this, function (response) {
if (response.error) {
errorHandler(response.error);
return;
}
var layerName = response.featureCollection.layers[0].layerDefinition.name;
// dom.byId('upload-status').innerHTML = '<b>Loaded: </b>' + layerName;
addShapefileToMap(response.featureCollection);
}),
error: lang.hitch(this, errorHandler)
});
}
function errorHandler(error) {
alert(error);
}
}, true);

}



}); //end of return
}); //end of define








share







New contributor




dhruv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    var submitcheck;
    define([
    'dojo/_base/declare',
    'dojo/_base/lang',
    'dojo/_base/array',
    'dojo/_base/Deferred',
    "dojo/number",
    "esri/sniff",
    "esri/config",
    'esri/request',
    'esri/geometry/Extent',
    'esri/toolbars/draw',
    'esri/geometry/Circle',
    'esri/geometry/Point',
    'esri/units',
    'esri/graphic',
    'esri/tasks/query',
    'esri/tasks/QueryTask',
    "esri/tasks/RelationshipQuery",
    "esri/geometry/scaleUtils",
    "esri/layers/FeatureLayer",
    "esri/renderers/SimpleRenderer",
    "dojo/promise/all",
    'esri/SpatialReference',
    'esri/dijit/InfoWindowLite',
    'esri/InfoTemplate',



     'dojo/request/xhr',
    'dojo/on',
    'dojo/dom',
    'dojo/topic',
    'dojo/dom-construct',

    "esri/geometry/webMercatorUtils",

    "dojo/colors",
    "dojo/fx/easing",
    "dojox/charting/Chart",
    "dojox/charting/axis2d/Default",
    "dojox/charting/plot2d/Grid",
    "dojox/charting/plot2d/Areas",
    "dojox/charting/plot2d/StackedAreas",
    "dojox/charting/action2d/MouseIndicator",
    "dojox/charting/action2d/TouchIndicator",
    "dojox/charting/themes/ThreeD",
    "dojox/charting/themes/Wetland",
    'dijit/form/Select',
    'dijit/form/Button',
    'dijit/form/DropDownButton',
    'dijit/form/ComboBox',
    'dijit/form/ValidationTextBox',
    'esri/geometry/geodesicUtils',

    'dijit/Dialog',
    'dijit/TooltipDialog',
    'dojox/grid/DataGrid',
    "esri/dijit/Measurement",

    'dijit/layout/ContentPane',
    'dijit/layout/BorderContainer',
    'dijit/layout/TabContainer',
    'dojo/data/ItemFileWriteStore',
    'esri/Color',
    'esri/tasks/LengthsParameters',
    'esri/tasks/GeometryService',
    'esri/tasks/Geoprocessor',
    'esri/tasks/FeatureSet',
    'esri/tasks/LinearUnit',

    'dijit/registry',
    'dijit/popup',
    'dojo/store/Memory',
    'dojo/data/ObjectStore',
    "esri/symbols/PictureMarkerSymbol",
    "esri/symbols/SimpleFillSymbol",
    'esri/symbols/SimpleLineSymbol',
    'esri/symbols/SimpleMarkerSymbol',
    'esri/symbols/CartographicLineSymbol',

    'app/mapconfig',
    'app/utils',
    'app/saploadquery',
    'app/messagebox',
    'dijit/popup',
    "dojo/json",
    "dojo/parser"

    ],
    function (declare, lang, arrayUtils, Deferred, number, sniff, esriConfig, request,
    Extent, Draw, Circle, Point, Units, Graphic, Query, QueryTask, RelationshipQuery, scaleUtils, FeatureLayer, SimpleRenderer, Promise, SpatialReference, InfoWindowLite, InfoTemplate,
    Xhr, On, dom, Topic, domConstruct, webMercatorUtils,
    colors, easing, Chart, Default, Grid, Areas, StackedAreas, MouseIndicator, TouchIndicator, ThreeD, Wetland,
    Select, Button, DropDownButton, ComboBox, ValidationTextBox, GeodesicUtils,
    Dialog, TooltipDialog, DataGrid, Measurement,
    ContentPane, BorderContainer, TabContainer,
    ItemFileWriteStore, Color, LengthsParameters, GeometryService, Geoprocessor, FeatureSet, LinearUnit,
    Registry, popup, Memory, ObjectStore, PictureMarkerSymbol, SimpleFillSymbol, SimpleLineSymbol, SimpleMarkerSymbol, CartographicLineSymbol,
    MapConfig, Utils, SapLoadQuery, mesgObj, popup, JSON, parser) {

    var mapConfig = new MapConfig();
    var cemUtils = new Utils();
    var map = null;
    var thisItem = null;

    return declare(null, {

    whoami: 'ADDSHAPEFILE',
    map: null,
    uname: null,
    newtooltipdialog: null,

    result_test: null,
    /* Constructor */
    constructor: function (map) {

    console.log("Loaded " + this.whoami);
    _map = map;
    this.map = map;
    // thisItem = this;
    // this.submitcheck();

    },
    submitcheck: function (event) {
    console.log();
    var a = dojo.byId("_form").value;
    // alert();


    },


    displayaddFileDialog: function (anchorID) {

    var contentpanenew = new ContentPane({
    id: 'contentpanenew',
    selected: 'true',
    content: '<div id="buttons" style="background-color:#E8E8E8;">Select files to upload by clicking on the Browse button <br/>'
    + '(Supported extension types: .zip)<br/><br/></div>'
    + '<form id="_form" data-dojo-attach-point="_form" name="_form" method="post" enctype="multipart/form-data" >'
    + '<input type = "file" id="uploadFileInput" data-dojo-attach-point="uploadFileInput" accept=".zip" name = "_file" style="width: 190px; opacity: 0.75; padding: 5px;"></input>'
    + '<br/>'
    + '<button id="submitButton" name="submitButton" type="submit" data-dojo-type="dijit/form/Button" style="margin-top: 10px;"> Submit </button>'
    + '<button id="closeUploadDialog" name="closeUploadDialog" data-dojo-type="dijit/form/Button" style="margin-top: 10px;"> Close </button>'

    + '</form><br/><br/>'

    });

    // onsubmit = "try: submitcheck()" target="_iframe"
    var newtooltipdialog = new TooltipDialog({ content: contentpanenew });
    newtooltipdialog.startup();

    On(dom.byId(anchorID), 'click', function () {
    if (dijit.byId(anchorID).get('disabled') == false) {
    popup.open({ popup: newtooltipdialog,
    around: dom.byId(anchorID),
    orient: ["below-centered"]
    });
    }
    }); // end of On
    // function submitcheck(event) {
    // alert();
    // }


    Registry.byId('submitButton').on('click', function (e) {
    // On(dom.byId("uploadForm"), "change", function (e) {
    parser.parse();

    var portalUrl = "https://www.arcgis.com";

    //esriConfig.defaults.io.proxyUrl = "/proxy/";
    // var a = document.getElementById('inFile').files[0];
    // var name_element = _file.value.toLowerCase();
    var name_element = dojo.byId("uploadFileInput").value;
    //alert(name_element);

    if (sniff("ie")) { //filename is full path in IE so extract the file name
    var arr = name_element.split("\");
    name_element = arr[arr.length - 1];
    }
    if (name_element.indexOf(".zip") !== -1) {//is file a zip - if not notify user
    // alert("this is a zip file");
    generateFeatureCollection(name_element);
    }
    else {
    alert("this is not a zip folder");
    }

    function generateFeatureCollection(name_element) {
    var namefeat = name_element.split(".");
    //Chrome and IE add c:fakepath to the value - we need to remove it
    //See this link for more info: http://davidwalsh.name/fakepath
    namefeat = namefeat[0].replace("c:\fakepath\", "");
    // namefeat = namefeat[0];
    // dom.byId('upload-status').innerHTML = '<b>Loading… </b>' + name;

    //Define the input params for generate see the rest doc for details
    //http://www.arcgis.com/apidocs/rest/index.html?generate.html
    var params = {
    'name': namefeat,
    'targetSR': _map.spatialReference,
    'maxRecordCount': 100000,
    'enforceInputFileSizeLimit': true,
    'enforceOutputJsonSizeLimit': true
    };

    //generalize features for display Here we generalize at 1:40,000 which is approx 10 meters
    //This should work well when using web mercator.
    var extent = scaleUtils.getExtentForScale(_map, 40000);
    var resolution = extent.getWidth() / _map.width;
    params.generalize = true;
    params.maxAllowableOffset = resolution;
    params.reducePrecision = true;
    params.numberOfDigitsAfterDecimal = 0;

    var myContent = {
    'filetype': 'shapefile',
    'publishParameters': JSON.stringify(params),
    'f': 'json',
    'callback.html': 'textarea'
    };
    var a = dom.byId('_form');
    var b = document.getElementById("uploadFileInput");
    var c = dojo.byId("uploadFileInput");


    // var uploadUrl = 'http://umario.cem-macau.com:6080/arcgis/rest/services/shapefiletolayernew/GPServer/uploads/upload';
    // var uploadRequest = request({
    // url: this.uploadUrl,
    // form: dom.byId("_form"),
    // handleAs: "json",
    // content: myContent
    // }, {
    // useProxy: true,
    // usePost: true
    // });
    // uploadRequest.then(lang.hitch(this, this.handleFileLoad), lang.hitch(this, this.handleFileLoadError));
    // showProgressDialog("Uploading Files.......", true);



                           //use the rest generate operation to generate a feature collection from the zipped shapefile
    request({
    url: 'http://umario.cem-macau.com:6080/arcgis/rest/services/shapefiletolayernew/GPServer/uploads/upload',
    // url: portalUrl + '/sharing/rest/content/features/generate',
    content: myContent,
    form: dojo.byId('_form'),
    handleAs: 'json',
    useProxy: true,
    usePost: true,
    load: lang.hitch(this, function (response) {
    if (response.error) {
    errorHandler(response.error);
    return;
    }
    var layerName = response.featureCollection.layers[0].layerDefinition.name;
    // dom.byId('upload-status').innerHTML = '<b>Loaded: </b>' + layerName;
    addShapefileToMap(response.featureCollection);
    }),
    error: lang.hitch(this, errorHandler)
    });
    }
    function errorHandler(error) {
    alert(error);
    }
    }, true);

    }



    }); //end of return
    }); //end of define








    share







    New contributor




    dhruv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      var submitcheck;
      define([
      'dojo/_base/declare',
      'dojo/_base/lang',
      'dojo/_base/array',
      'dojo/_base/Deferred',
      "dojo/number",
      "esri/sniff",
      "esri/config",
      'esri/request',
      'esri/geometry/Extent',
      'esri/toolbars/draw',
      'esri/geometry/Circle',
      'esri/geometry/Point',
      'esri/units',
      'esri/graphic',
      'esri/tasks/query',
      'esri/tasks/QueryTask',
      "esri/tasks/RelationshipQuery",
      "esri/geometry/scaleUtils",
      "esri/layers/FeatureLayer",
      "esri/renderers/SimpleRenderer",
      "dojo/promise/all",
      'esri/SpatialReference',
      'esri/dijit/InfoWindowLite',
      'esri/InfoTemplate',



       'dojo/request/xhr',
      'dojo/on',
      'dojo/dom',
      'dojo/topic',
      'dojo/dom-construct',

      "esri/geometry/webMercatorUtils",

      "dojo/colors",
      "dojo/fx/easing",
      "dojox/charting/Chart",
      "dojox/charting/axis2d/Default",
      "dojox/charting/plot2d/Grid",
      "dojox/charting/plot2d/Areas",
      "dojox/charting/plot2d/StackedAreas",
      "dojox/charting/action2d/MouseIndicator",
      "dojox/charting/action2d/TouchIndicator",
      "dojox/charting/themes/ThreeD",
      "dojox/charting/themes/Wetland",
      'dijit/form/Select',
      'dijit/form/Button',
      'dijit/form/DropDownButton',
      'dijit/form/ComboBox',
      'dijit/form/ValidationTextBox',
      'esri/geometry/geodesicUtils',

      'dijit/Dialog',
      'dijit/TooltipDialog',
      'dojox/grid/DataGrid',
      "esri/dijit/Measurement",

      'dijit/layout/ContentPane',
      'dijit/layout/BorderContainer',
      'dijit/layout/TabContainer',
      'dojo/data/ItemFileWriteStore',
      'esri/Color',
      'esri/tasks/LengthsParameters',
      'esri/tasks/GeometryService',
      'esri/tasks/Geoprocessor',
      'esri/tasks/FeatureSet',
      'esri/tasks/LinearUnit',

      'dijit/registry',
      'dijit/popup',
      'dojo/store/Memory',
      'dojo/data/ObjectStore',
      "esri/symbols/PictureMarkerSymbol",
      "esri/symbols/SimpleFillSymbol",
      'esri/symbols/SimpleLineSymbol',
      'esri/symbols/SimpleMarkerSymbol',
      'esri/symbols/CartographicLineSymbol',

      'app/mapconfig',
      'app/utils',
      'app/saploadquery',
      'app/messagebox',
      'dijit/popup',
      "dojo/json",
      "dojo/parser"

      ],
      function (declare, lang, arrayUtils, Deferred, number, sniff, esriConfig, request,
      Extent, Draw, Circle, Point, Units, Graphic, Query, QueryTask, RelationshipQuery, scaleUtils, FeatureLayer, SimpleRenderer, Promise, SpatialReference, InfoWindowLite, InfoTemplate,
      Xhr, On, dom, Topic, domConstruct, webMercatorUtils,
      colors, easing, Chart, Default, Grid, Areas, StackedAreas, MouseIndicator, TouchIndicator, ThreeD, Wetland,
      Select, Button, DropDownButton, ComboBox, ValidationTextBox, GeodesicUtils,
      Dialog, TooltipDialog, DataGrid, Measurement,
      ContentPane, BorderContainer, TabContainer,
      ItemFileWriteStore, Color, LengthsParameters, GeometryService, Geoprocessor, FeatureSet, LinearUnit,
      Registry, popup, Memory, ObjectStore, PictureMarkerSymbol, SimpleFillSymbol, SimpleLineSymbol, SimpleMarkerSymbol, CartographicLineSymbol,
      MapConfig, Utils, SapLoadQuery, mesgObj, popup, JSON, parser) {

      var mapConfig = new MapConfig();
      var cemUtils = new Utils();
      var map = null;
      var thisItem = null;

      return declare(null, {

      whoami: 'ADDSHAPEFILE',
      map: null,
      uname: null,
      newtooltipdialog: null,

      result_test: null,
      /* Constructor */
      constructor: function (map) {

      console.log("Loaded " + this.whoami);
      _map = map;
      this.map = map;
      // thisItem = this;
      // this.submitcheck();

      },
      submitcheck: function (event) {
      console.log();
      var a = dojo.byId("_form").value;
      // alert();


      },


      displayaddFileDialog: function (anchorID) {

      var contentpanenew = new ContentPane({
      id: 'contentpanenew',
      selected: 'true',
      content: '<div id="buttons" style="background-color:#E8E8E8;">Select files to upload by clicking on the Browse button <br/>'
      + '(Supported extension types: .zip)<br/><br/></div>'
      + '<form id="_form" data-dojo-attach-point="_form" name="_form" method="post" enctype="multipart/form-data" >'
      + '<input type = "file" id="uploadFileInput" data-dojo-attach-point="uploadFileInput" accept=".zip" name = "_file" style="width: 190px; opacity: 0.75; padding: 5px;"></input>'
      + '<br/>'
      + '<button id="submitButton" name="submitButton" type="submit" data-dojo-type="dijit/form/Button" style="margin-top: 10px;"> Submit </button>'
      + '<button id="closeUploadDialog" name="closeUploadDialog" data-dojo-type="dijit/form/Button" style="margin-top: 10px;"> Close </button>'

      + '</form><br/><br/>'

      });

      // onsubmit = "try: submitcheck()" target="_iframe"
      var newtooltipdialog = new TooltipDialog({ content: contentpanenew });
      newtooltipdialog.startup();

      On(dom.byId(anchorID), 'click', function () {
      if (dijit.byId(anchorID).get('disabled') == false) {
      popup.open({ popup: newtooltipdialog,
      around: dom.byId(anchorID),
      orient: ["below-centered"]
      });
      }
      }); // end of On
      // function submitcheck(event) {
      // alert();
      // }


      Registry.byId('submitButton').on('click', function (e) {
      // On(dom.byId("uploadForm"), "change", function (e) {
      parser.parse();

      var portalUrl = "https://www.arcgis.com";

      //esriConfig.defaults.io.proxyUrl = "/proxy/";
      // var a = document.getElementById('inFile').files[0];
      // var name_element = _file.value.toLowerCase();
      var name_element = dojo.byId("uploadFileInput").value;
      //alert(name_element);

      if (sniff("ie")) { //filename is full path in IE so extract the file name
      var arr = name_element.split("\");
      name_element = arr[arr.length - 1];
      }
      if (name_element.indexOf(".zip") !== -1) {//is file a zip - if not notify user
      // alert("this is a zip file");
      generateFeatureCollection(name_element);
      }
      else {
      alert("this is not a zip folder");
      }

      function generateFeatureCollection(name_element) {
      var namefeat = name_element.split(".");
      //Chrome and IE add c:fakepath to the value - we need to remove it
      //See this link for more info: http://davidwalsh.name/fakepath
      namefeat = namefeat[0].replace("c:\fakepath\", "");
      // namefeat = namefeat[0];
      // dom.byId('upload-status').innerHTML = '<b>Loading… </b>' + name;

      //Define the input params for generate see the rest doc for details
      //http://www.arcgis.com/apidocs/rest/index.html?generate.html
      var params = {
      'name': namefeat,
      'targetSR': _map.spatialReference,
      'maxRecordCount': 100000,
      'enforceInputFileSizeLimit': true,
      'enforceOutputJsonSizeLimit': true
      };

      //generalize features for display Here we generalize at 1:40,000 which is approx 10 meters
      //This should work well when using web mercator.
      var extent = scaleUtils.getExtentForScale(_map, 40000);
      var resolution = extent.getWidth() / _map.width;
      params.generalize = true;
      params.maxAllowableOffset = resolution;
      params.reducePrecision = true;
      params.numberOfDigitsAfterDecimal = 0;

      var myContent = {
      'filetype': 'shapefile',
      'publishParameters': JSON.stringify(params),
      'f': 'json',
      'callback.html': 'textarea'
      };
      var a = dom.byId('_form');
      var b = document.getElementById("uploadFileInput");
      var c = dojo.byId("uploadFileInput");


      // var uploadUrl = 'http://umario.cem-macau.com:6080/arcgis/rest/services/shapefiletolayernew/GPServer/uploads/upload';
      // var uploadRequest = request({
      // url: this.uploadUrl,
      // form: dom.byId("_form"),
      // handleAs: "json",
      // content: myContent
      // }, {
      // useProxy: true,
      // usePost: true
      // });
      // uploadRequest.then(lang.hitch(this, this.handleFileLoad), lang.hitch(this, this.handleFileLoadError));
      // showProgressDialog("Uploading Files.......", true);



                             //use the rest generate operation to generate a feature collection from the zipped shapefile
      request({
      url: 'http://umario.cem-macau.com:6080/arcgis/rest/services/shapefiletolayernew/GPServer/uploads/upload',
      // url: portalUrl + '/sharing/rest/content/features/generate',
      content: myContent,
      form: dojo.byId('_form'),
      handleAs: 'json',
      useProxy: true,
      usePost: true,
      load: lang.hitch(this, function (response) {
      if (response.error) {
      errorHandler(response.error);
      return;
      }
      var layerName = response.featureCollection.layers[0].layerDefinition.name;
      // dom.byId('upload-status').innerHTML = '<b>Loaded: </b>' + layerName;
      addShapefileToMap(response.featureCollection);
      }),
      error: lang.hitch(this, errorHandler)
      });
      }
      function errorHandler(error) {
      alert(error);
      }
      }, true);

      }



      }); //end of return
      }); //end of define








      share







      New contributor




      dhruv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      var submitcheck;
      define([
      'dojo/_base/declare',
      'dojo/_base/lang',
      'dojo/_base/array',
      'dojo/_base/Deferred',
      "dojo/number",
      "esri/sniff",
      "esri/config",
      'esri/request',
      'esri/geometry/Extent',
      'esri/toolbars/draw',
      'esri/geometry/Circle',
      'esri/geometry/Point',
      'esri/units',
      'esri/graphic',
      'esri/tasks/query',
      'esri/tasks/QueryTask',
      "esri/tasks/RelationshipQuery",
      "esri/geometry/scaleUtils",
      "esri/layers/FeatureLayer",
      "esri/renderers/SimpleRenderer",
      "dojo/promise/all",
      'esri/SpatialReference',
      'esri/dijit/InfoWindowLite',
      'esri/InfoTemplate',



       'dojo/request/xhr',
      'dojo/on',
      'dojo/dom',
      'dojo/topic',
      'dojo/dom-construct',

      "esri/geometry/webMercatorUtils",

      "dojo/colors",
      "dojo/fx/easing",
      "dojox/charting/Chart",
      "dojox/charting/axis2d/Default",
      "dojox/charting/plot2d/Grid",
      "dojox/charting/plot2d/Areas",
      "dojox/charting/plot2d/StackedAreas",
      "dojox/charting/action2d/MouseIndicator",
      "dojox/charting/action2d/TouchIndicator",
      "dojox/charting/themes/ThreeD",
      "dojox/charting/themes/Wetland",
      'dijit/form/Select',
      'dijit/form/Button',
      'dijit/form/DropDownButton',
      'dijit/form/ComboBox',
      'dijit/form/ValidationTextBox',
      'esri/geometry/geodesicUtils',

      'dijit/Dialog',
      'dijit/TooltipDialog',
      'dojox/grid/DataGrid',
      "esri/dijit/Measurement",

      'dijit/layout/ContentPane',
      'dijit/layout/BorderContainer',
      'dijit/layout/TabContainer',
      'dojo/data/ItemFileWriteStore',
      'esri/Color',
      'esri/tasks/LengthsParameters',
      'esri/tasks/GeometryService',
      'esri/tasks/Geoprocessor',
      'esri/tasks/FeatureSet',
      'esri/tasks/LinearUnit',

      'dijit/registry',
      'dijit/popup',
      'dojo/store/Memory',
      'dojo/data/ObjectStore',
      "esri/symbols/PictureMarkerSymbol",
      "esri/symbols/SimpleFillSymbol",
      'esri/symbols/SimpleLineSymbol',
      'esri/symbols/SimpleMarkerSymbol',
      'esri/symbols/CartographicLineSymbol',

      'app/mapconfig',
      'app/utils',
      'app/saploadquery',
      'app/messagebox',
      'dijit/popup',
      "dojo/json",
      "dojo/parser"

      ],
      function (declare, lang, arrayUtils, Deferred, number, sniff, esriConfig, request,
      Extent, Draw, Circle, Point, Units, Graphic, Query, QueryTask, RelationshipQuery, scaleUtils, FeatureLayer, SimpleRenderer, Promise, SpatialReference, InfoWindowLite, InfoTemplate,
      Xhr, On, dom, Topic, domConstruct, webMercatorUtils,
      colors, easing, Chart, Default, Grid, Areas, StackedAreas, MouseIndicator, TouchIndicator, ThreeD, Wetland,
      Select, Button, DropDownButton, ComboBox, ValidationTextBox, GeodesicUtils,
      Dialog, TooltipDialog, DataGrid, Measurement,
      ContentPane, BorderContainer, TabContainer,
      ItemFileWriteStore, Color, LengthsParameters, GeometryService, Geoprocessor, FeatureSet, LinearUnit,
      Registry, popup, Memory, ObjectStore, PictureMarkerSymbol, SimpleFillSymbol, SimpleLineSymbol, SimpleMarkerSymbol, CartographicLineSymbol,
      MapConfig, Utils, SapLoadQuery, mesgObj, popup, JSON, parser) {

      var mapConfig = new MapConfig();
      var cemUtils = new Utils();
      var map = null;
      var thisItem = null;

      return declare(null, {

      whoami: 'ADDSHAPEFILE',
      map: null,
      uname: null,
      newtooltipdialog: null,

      result_test: null,
      /* Constructor */
      constructor: function (map) {

      console.log("Loaded " + this.whoami);
      _map = map;
      this.map = map;
      // thisItem = this;
      // this.submitcheck();

      },
      submitcheck: function (event) {
      console.log();
      var a = dojo.byId("_form").value;
      // alert();


      },


      displayaddFileDialog: function (anchorID) {

      var contentpanenew = new ContentPane({
      id: 'contentpanenew',
      selected: 'true',
      content: '<div id="buttons" style="background-color:#E8E8E8;">Select files to upload by clicking on the Browse button <br/>'
      + '(Supported extension types: .zip)<br/><br/></div>'
      + '<form id="_form" data-dojo-attach-point="_form" name="_form" method="post" enctype="multipart/form-data" >'
      + '<input type = "file" id="uploadFileInput" data-dojo-attach-point="uploadFileInput" accept=".zip" name = "_file" style="width: 190px; opacity: 0.75; padding: 5px;"></input>'
      + '<br/>'
      + '<button id="submitButton" name="submitButton" type="submit" data-dojo-type="dijit/form/Button" style="margin-top: 10px;"> Submit </button>'
      + '<button id="closeUploadDialog" name="closeUploadDialog" data-dojo-type="dijit/form/Button" style="margin-top: 10px;"> Close </button>'

      + '</form><br/><br/>'

      });

      // onsubmit = "try: submitcheck()" target="_iframe"
      var newtooltipdialog = new TooltipDialog({ content: contentpanenew });
      newtooltipdialog.startup();

      On(dom.byId(anchorID), 'click', function () {
      if (dijit.byId(anchorID).get('disabled') == false) {
      popup.open({ popup: newtooltipdialog,
      around: dom.byId(anchorID),
      orient: ["below-centered"]
      });
      }
      }); // end of On
      // function submitcheck(event) {
      // alert();
      // }


      Registry.byId('submitButton').on('click', function (e) {
      // On(dom.byId("uploadForm"), "change", function (e) {
      parser.parse();

      var portalUrl = "https://www.arcgis.com";

      //esriConfig.defaults.io.proxyUrl = "/proxy/";
      // var a = document.getElementById('inFile').files[0];
      // var name_element = _file.value.toLowerCase();
      var name_element = dojo.byId("uploadFileInput").value;
      //alert(name_element);

      if (sniff("ie")) { //filename is full path in IE so extract the file name
      var arr = name_element.split("\");
      name_element = arr[arr.length - 1];
      }
      if (name_element.indexOf(".zip") !== -1) {//is file a zip - if not notify user
      // alert("this is a zip file");
      generateFeatureCollection(name_element);
      }
      else {
      alert("this is not a zip folder");
      }

      function generateFeatureCollection(name_element) {
      var namefeat = name_element.split(".");
      //Chrome and IE add c:fakepath to the value - we need to remove it
      //See this link for more info: http://davidwalsh.name/fakepath
      namefeat = namefeat[0].replace("c:\fakepath\", "");
      // namefeat = namefeat[0];
      // dom.byId('upload-status').innerHTML = '<b>Loading… </b>' + name;

      //Define the input params for generate see the rest doc for details
      //http://www.arcgis.com/apidocs/rest/index.html?generate.html
      var params = {
      'name': namefeat,
      'targetSR': _map.spatialReference,
      'maxRecordCount': 100000,
      'enforceInputFileSizeLimit': true,
      'enforceOutputJsonSizeLimit': true
      };

      //generalize features for display Here we generalize at 1:40,000 which is approx 10 meters
      //This should work well when using web mercator.
      var extent = scaleUtils.getExtentForScale(_map, 40000);
      var resolution = extent.getWidth() / _map.width;
      params.generalize = true;
      params.maxAllowableOffset = resolution;
      params.reducePrecision = true;
      params.numberOfDigitsAfterDecimal = 0;

      var myContent = {
      'filetype': 'shapefile',
      'publishParameters': JSON.stringify(params),
      'f': 'json',
      'callback.html': 'textarea'
      };
      var a = dom.byId('_form');
      var b = document.getElementById("uploadFileInput");
      var c = dojo.byId("uploadFileInput");


      // var uploadUrl = 'http://umario.cem-macau.com:6080/arcgis/rest/services/shapefiletolayernew/GPServer/uploads/upload';
      // var uploadRequest = request({
      // url: this.uploadUrl,
      // form: dom.byId("_form"),
      // handleAs: "json",
      // content: myContent
      // }, {
      // useProxy: true,
      // usePost: true
      // });
      // uploadRequest.then(lang.hitch(this, this.handleFileLoad), lang.hitch(this, this.handleFileLoadError));
      // showProgressDialog("Uploading Files.......", true);



                             //use the rest generate operation to generate a feature collection from the zipped shapefile
      request({
      url: 'http://umario.cem-macau.com:6080/arcgis/rest/services/shapefiletolayernew/GPServer/uploads/upload',
      // url: portalUrl + '/sharing/rest/content/features/generate',
      content: myContent,
      form: dojo.byId('_form'),
      handleAs: 'json',
      useProxy: true,
      usePost: true,
      load: lang.hitch(this, function (response) {
      if (response.error) {
      errorHandler(response.error);
      return;
      }
      var layerName = response.featureCollection.layers[0].layerDefinition.name;
      // dom.byId('upload-status').innerHTML = '<b>Loaded: </b>' + layerName;
      addShapefileToMap(response.featureCollection);
      }),
      error: lang.hitch(this, errorHandler)
      });
      }
      function errorHandler(error) {
      alert(error);
      }
      }, true);

      }



      }); //end of return
      }); //end of define






      shapefile arcgis-server error





      share







      New contributor




      dhruv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      dhruv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      dhruv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 3 mins ago









      dhruvdhruv

      1




      1




      New contributor




      dhruv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      dhruv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      dhruv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          dhruv is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f314809%2fnot-able-to-upload-shapefile-in-arcgis-3-10-with-custom-built-gp-service-with-er%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          dhruv is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          dhruv is a new contributor. Be nice, and check out our Code of Conduct.













          dhruv is a new contributor. Be nice, and check out our Code of Conduct.












          dhruv is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f314809%2fnot-able-to-upload-shapefile-in-arcgis-3-10-with-custom-built-gp-service-with-er%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

          Meter-Bus Содержание Параметры шины | Стандартизация |...