/// <summary> /// With the Feature Service having been created, lets add the attribution definition to /// it to make the service a functional, fully qualified feature service.. /// </summary> /// <param name="geometryType"></param> /// <returns></returns> private bool AddDefinitionToLayer(GeometryType geometryType) { Extent extent = null; PointSymbol symbol = null; Renderer renderer = null; DrawingInfo drawingInfo = null; List<object> fields = new List<object>(); Template template = null; EditorTrackingInfo editorTrackingInfo = null; AdminLayerInfoAttribute adminLayerInfo = null; DefinitionLayer layer = null; string formattedRequest = string.Empty; string jsonResponse = string.Empty; FeatureLayerAttributes featLayerAttributes = null; this.Cursor = Cursors.WaitCursor; featLayerAttributes = new FeatureLayerAttributes(); //write in your default extent values here: extent = new Extent() { xmin = -14999999.999999743, ymin = 1859754.5323447795, xmax = -6199999.999999896, ymax = 7841397.327701188, spatialReference = new SpatialReference() { wkid = 102100, latestWkid = 3857 }, }; var json = string.Empty; if (geometryType == GeometryType.point) { symbol = new PointSymbol() { type = "esriPMS", url = "RedSphere.png", imageData = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQBQYWludC5ORVQgdjMuNS4xTuc4+QAAB3VJREFUeF7tmPlTlEcexnve94U5mANQbgQSbgiHXHINlxpRIBpRI6wHorLERUmIisKCQWM8cqigESVQS1Kx1piNi4mW2YpbcZONrilE140RCTcy3DDAcL/zbJP8CYPDL+9Ufau7uqb7eZ7P+/a8PS8hwkcgIBAQCAgEBAICAYGAQEAgIBAQCAgEBAICAYGAQEAgIBAQCDx/AoowKXFMUhD3lQrioZaQRVRS+fxl51eBTZUTdZ41U1Rox13/0JF9csGJ05Qv4jSz/YPWohtvLmSKN5iTGGqTm1+rc6weICOBRbZs1UVnrv87T1PUeovxyNsUP9P6n5cpHtCxu24cbrmwKLdj+osWiqrVKhI0xzbmZ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gYBAQCAgEBAICAQEAgIBgYBAQCAgEBAICAQEAv8H44b/6ZiGvGAAAAAASUVORK5CYII=", contentType = "image/png", color = null, width = 15, height = 15, angle = 0, xoffset = 0, yoffset = 0 }; renderer = new PointRenderer() { type = "simple", symbol = symbol, label = "", description = "" }; } else //POLYGON: with unique value rendering { renderer = UniqueValueRender(); json = new JavaScriptSerializer().Serialize(renderer); //json = "{\"renderer\" : {\"type\": \"uniqueValue\",\"field1\": \"" + cboFields.Text + "\",\"field2\": \"\",\"field3\": \"\","; //json += "\"fieldDelimiter\": \"\",\"defaultSymbol\": {\"type\": \"esriSFS\",\"style\": \"esriSFSSolid\",\"color\": [198,245,215,255],"; //json += "\"outline\": {\"type\": \"esriSLS\",\"style\": \"esriSLSSolid\",\"color\": [110,110,110,255],\"width\": 1}},"; //json += "\"defaultLabel\": \"<all other values>\",\"uniqueValueInfos\": [" + Colors(); //json += "]}, \"transparency\" : " + hScrollBar2.Value + ", \"labelingInfo\": null}"; } drawingInfo = new DrawingInfo() { renderer = json,//renderer, transparency = 50, labelingInfo = null }; var drawinfo = new JavaScriptSerializer().Serialize(drawingInfo); Fields(fields); if (geometryType == GeometryType.polygon) { template = new Template() { name = "New Feature", description = "", drawingTool = "esriFeatureEditToolPolygon", prototype = new Prototype() { attributes = new Attributes() } }; } editorTrackingInfo = new EditorTrackingInfo() { enableEditorTracking = false, enableOwnershipAccessControl = false, allowOthersToUpdate = true, allowOthersToDelete = true }; adminLayerInfo = new AdminLayerInfoAttribute() { geometryField = new GeometryField() { name = "Shape", srid = 102100 } }; layer = new DefinitionLayer() { currentVersion = 10.11, id = 0, name = _featureServiceCreationResponse.Name, type = featLayerAttributes != null ? featLayerAttributes.type != null ? featLayerAttributes.type : "Feature Layer" : "Feature Layer", displayField = featLayerAttributes != null ? featLayerAttributes.displayField != null ? featLayerAttributes.displayField : "" : "", description = "", copyrightText = featLayerAttributes != null ? featLayerAttributes.copyrightText != null ? featLayerAttributes.copyrightText : "" : "", defaultVisibility = true, relationships = featLayerAttributes != null ? featLayerAttributes.relationShips != null ? featLayerAttributes.relationShips : new object[] { } : new object[] { }, isDataVersioned = featLayerAttributes != null ? featLayerAttributes.isDataVersioned : false, supportsRollbackOnFailureParameter = true, supportsStatistics = true, supportsAdvancedQueries = true, geometryType = featLayerAttributes != null ? featLayerAttributes.geometryType != null ? featLayerAttributes.geometryType : "esriGeometryPolygon" : "esriGeometryPoint", minScale = featLayerAttributes != null ? featLayerAttributes.minScale : 0, maxScale = featLayerAttributes != null ? featLayerAttributes.maxScale : 0, extent = extent, drawingInfo = json, allowGeometryUpdates = true, hasAttachments = featLayerAttributes != null ? featLayerAttributes.hasAttachments : false, htmlPopupType = featLayerAttributes != null ? featLayerAttributes.htmlPopupType != null ? featLayerAttributes.htmlPopupType : "esriServerHTMLPopupTypeNone" : "esriServerHTMLPopupTypeNone", hasM = featLayerAttributes != null ? featLayerAttributes.hasM : false, hasZ = featLayerAttributes != null ? featLayerAttributes.hasZ : false, objectIdField = featLayerAttributes != null ? featLayerAttributes.objectIdField != null ? featLayerAttributes.objectIdField : "OBJECTID" : "OBJECTID", globalIdField = featLayerAttributes != null ? featLayerAttributes.globalIdField != null ? featLayerAttributes.globalIdField : "" : "", typeIdField = featLayerAttributes != null ? featLayerAttributes.typeIdField != null ? featLayerAttributes.typeIdField : "" : "", fields = fields.ToArray(), types = featLayerAttributes != null ? featLayerAttributes.types != null ? featLayerAttributes.types : new object[0] : new object[0], templates = new Template[1] { template }, supportedQueryFormats = featLayerAttributes != null ? featLayerAttributes.supportedQueryFormats != null ? featLayerAttributes.supportedQueryFormats : "JSON" : "JSON", hasStaticData = featLayerAttributes != null ? featLayerAttributes.hasStaticData : false, maxRecordCount = 2000, capabilities = featLayerAttributes != null ? featLayerAttributes.capabilities != null ? featLayerAttributes.capabilities : "Query,Editing,Create,Update,Delete" : "Query,Editing,Create,Update,Delete", adminLayerInfo = adminLayerInfo }; DefinitionLayer[] layers = new DefinitionLayer[1] { layer }; AddDefinition definition = new AddDefinition() { layers = layers }; string serviceEndPoint = "http://services.arcgis.com/"; string serviceEndPoint2 = "http://services1.arcgis.com/";//NB: Trial Account endpoint!!!! string featureServiceName = _featureServiceCreationResponse.Name; if (featureServiceName == null) featureServiceName = txtFeatureServiceName.Text; string requestURL = string.Format("{0}{1}/arcgis/admin/services/{2}.FeatureServer/AddToDefinition", serviceEndPoint, _arcgGISOnlineOrganizationID, _featureServiceCreationResponse.Name); bool b = RequestAndResponseHandler.AddToFeatureServiceDefinition(requestURL, definition, _arcgGISOnlineOrganizationToken, _arcgGISOnlineOrganizationEndpoint, out formattedRequest, out jsonResponse); label32.Text = "Success: False"; this.Cursor = Cursors.Default; if (!b) { requestURL = string.Format("{0}{1}/arcgis/admin/services/{2}.FeatureServer/AddToDefinition", serviceEndPoint2, _arcgGISOnlineOrganizationID, _featureServiceCreationResponse.Name); b = RequestAndResponseHandler.AddToFeatureServiceDefinition(requestURL, definition, _arcgGISOnlineOrganizationToken, _arcgGISOnlineOrganizationEndpoint, out formattedRequest, out jsonResponse); } if (b) { label32.Text = "Success: True"; //TODO: add records btnUpdate.Enabled = true; } return b; }
/// <summary> /// NB: This code creates a point feature service if nothing has been selected in the "My Feature Services Info -> Items combobox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddDefinitionToLayer_Click(object sender, EventArgs e) { Item item = null; Extent extent = null; Symbol symbol = null; Renderer renderer = null; DrawingInfo drawingInfo = null; object[] fields = null; Template template = null; EditorTrackingInfo editorTrackingInfo = null; AdminLayerInfoAttribute adminLayerInfo = null; DefinitionLayer layer = null; string formattedRequest = string.Empty; string jsonResponse = string.Empty; FeatureLayerAttributes featLayerAttributes = null; this.Cursor = Cursors.WaitCursor; //NB: From the Items combobox if you have a feature service selected, this is the attribute table structure that will be used for the //creation of the new service. Otherwise create a new featureLayerAttributes class as set up in this code. // if (chkbxUseSelectedFS.Checked) { string[] concatenatedText = cboItems.Text.Split(':'); string split = concatenatedText[1].Replace(" ID", ""); if (_myOrganizationalContent.TryGetValue(cboItems.Text, out item)) if(item != null) if(item.url != null) featLayerAttributes = RequestAndResponseHandler.GetFeatureServiceAttributes(item.url, _token, out formattedRequest, out jsonResponse); try { if (featLayerAttributes == null) _featureServiceAttributesDataDictionary.TryGetValue(split.Trim(), out _featureLayerAttributes); } catch { } } if (featLayerAttributes == null) if (_featureLayerAttributes != null) featLayerAttributes = _featureLayerAttributes; else featLayerAttributes = new FeatureLayerAttributes(); //ensure that we have all that we need for a successful feature layer attributes push // if(featLayerAttributes.extent != null) extent = featLayerAttributes.extent; else { //write in your default extent values here: extent = new Extent() { xmin = -14999999.999999743, ymin = 1859754.5323447795, xmax = -6199999.999999896, ymax = 7841397.327701188, spatialReference = new SpatialReference() { wkid = 102100, latestWkid = 3857 }, }; } if (featLayerAttributes.drawingInfo != null) drawingInfo = featLayerAttributes.drawingInfo; else { symbol = new PointSymbol() { type = "esriPMS", url = "RedSphere.png", imageData = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQBQYWludC5ORVQgdjMuNS4xTuc4+QAAB3VJREFUeF7tmPlTlEcexnve94U5mANQbgQSbgiHXHINlxpRIBpRI6wHorLERUmIisKCQWM8cqigESVQS1Kx1piNi4mW2YpbcZONrilE140RCTcy3DDAcL/zbJP8CYPDL+9Ufau7uqb7eZ7P+/a8PS8hwkcgIBAQCAgEBAICAYGAQEAgIBAQCAgEBAICAYGAQEAgIBAQCDx/AoowKXFMUhD3lQrioZaQRVRS+fxl51eBTZUTdZ41U1Rox13/0JF9csGJ05Qv4jSz/YPWohtvLmSKN5iTGGqTm1+rc6weICOBRbZs1UVnrv87T1PUeovxyNsUP9P6n5cpHtCxu24cbrmwKLdj+osWiqrVKhI0xzbmZ7m1Sp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CAgEBAICAQEAgIBgYBAQCAgEBAICAQEAv8H44b/6ZiGvGAAAAAASUVORK5CYII=", contentType = "image/png", color = null, width = 15, height = 15, angle = 0, xoffset = 0, yoffset = 0 }; renderer = new PointRenderer() { type = "simple", symbol = symbol, label = "", description = "" }; drawingInfo = new DrawingInfo() { renderer = renderer, labelingInfo = null }; } if (featLayerAttributes.fields != null) fields = featLayerAttributes.fields; else { Field field = new Field() { name = "Longitude", type = "esriFieldTypeDouble", alias = "Longitude", sqlType = "sqlTypeFloat", nullable = true, editable = true, domain = null, defaultValue = null }; Field field2 = new Field() { name = "Latitude", type = "esriFieldTypeDouble", alias = "Latitude", sqlType = "sqlTypeFloat", nullable = true, editable = true, domain = null, defaultValue = null }; FieldString field3 = new FieldString() { name = "Name", type = "esriFieldTypeString", alias = "Name", sqlType = "sqlTypeNVarchar", length = 256, nullable = true, editable = true, domain = null, defaultValue = null }; FieldString field4 = new FieldString() { name = "Address", type = "esriFieldTypeString", alias = "Address", sqlType = "sqlTypeNVarchar", length = 256, nullable = true, editable = true, domain = null, defaultValue = null }; //DO NOT CHANGE PROPERTIES BELOW Field fieldFID = new Field() { name = "FID", type = "esriFieldTypeInteger", alias = "FID", sqlType = "sqlTypeInteger", nullable = false, editable = false, domain = null, defaultValue = null }; //object array so that we can contain different types within. //Field type double for example does not contain a length parameter. Hence we need different field type //representation. Unexpected properties for data types will cause a failure on the server end. fields = new object[5] { field, field2, field3, field4, fieldFID }; } if (featLayerAttributes.templates != null) template = featLayerAttributes.templates[0]; else { template = new Template() { name = "New Feature", description = "", drawingTool = "esriFeatureEditToolPoint", prototype = new Prototype() { attributes = new Attributes() } }; } editorTrackingInfo = new EditorTrackingInfo() { enableEditorTracking = false, enableOwnershipAccessControl = false, allowOthersToUpdate = true, allowOthersToDelete = true }; adminLayerInfo = new AdminLayerInfoAttribute() { geometryField = new GeometryField() { name = "Shape", srid = 102100 } }; layer = new DefinitionLayer() { currentVersion = featLayerAttributes != null ? featLayerAttributes.currentVersion : 10.11, id = 0, name = featLayerAttributes != null ? featLayerAttributes.name != null ? featLayerAttributes.name : txtFeatureServiceName.Text : txtFeatureServiceName.Text, type = featLayerAttributes != null ? featLayerAttributes.type != null ? featLayerAttributes.type : "Feature Layer" : "Feature Layer", displayField = featLayerAttributes != null ? featLayerAttributes.displayField != null ? featLayerAttributes.displayField : "" : "", description = "", copyrightText = featLayerAttributes != null ? featLayerAttributes.copyrightText != null ? featLayerAttributes.copyrightText : "" : "", defaultVisibility = featLayerAttributes != null ? featLayerAttributes.defaultVisibility != null ? featLayerAttributes.defaultVisibility : true : true, relationships = featLayerAttributes != null ? featLayerAttributes.relationShips != null ? featLayerAttributes.relationShips : new object[]{} : new object[] { }, isDataVersioned = featLayerAttributes != null ? featLayerAttributes.isDataVersioned : false, supportsRollbackOnFailureParameter = true, supportsAdvancedQueries = true, geometryType = featLayerAttributes != null ? featLayerAttributes.geometryType != null ? featLayerAttributes.geometryType : "esriGeometryPoint" : "esriGeometryPoint", minScale = featLayerAttributes != null ? featLayerAttributes.minScale : 0, maxScale = featLayerAttributes != null ? featLayerAttributes.maxScale : 0, extent = extent, drawingInfo = _javaScriptSerializer.Serialize(drawingInfo), allowGeometryUpdates = featLayerAttributes != null ? featLayerAttributes.allowGeometryUpdates != null ? featLayerAttributes.allowGeometryUpdates : true : true, hasAttachments = featLayerAttributes != null ? featLayerAttributes.hasAttachments : false, htmlPopupType = featLayerAttributes != null ? featLayerAttributes.htmlPopupType != null ? featLayerAttributes.htmlPopupType : "esriServerHTMLPopupTypeNone" : "esriServerHTMLPopupTypeNone", hasM = featLayerAttributes != null ? featLayerAttributes.hasM : false, hasZ = featLayerAttributes != null ? featLayerAttributes.hasZ : false, objectIdField = featLayerAttributes != null ? featLayerAttributes.objectIdField != null ? featLayerAttributes.objectIdField : "FID" : "FID", globalIdField = featLayerAttributes != null ? featLayerAttributes.globalIdField != null ? featLayerAttributes.globalIdField : "" : "", typeIdField = featLayerAttributes != null ? featLayerAttributes.typeIdField != null ? featLayerAttributes.typeIdField : "" : "", fields = fields, types = featLayerAttributes != null ? featLayerAttributes.types != null ? featLayerAttributes.types : new object[0] : new object[0], templates = new Template[1] { template }, supportedQueryFormats = featLayerAttributes != null ? featLayerAttributes.supportedQueryFormats != null ? featLayerAttributes.supportedQueryFormats: "JSON" : "JSON", hasStaticData = featLayerAttributes != null ? featLayerAttributes.hasStaticData : false, maxRecordCount = 2000,//featLayerAttributes != null ? featLayerAttributes.maxRecordCount != null ? featLayerAttributes.maxRecordCount : 200000 : 200000, capabilities = featLayerAttributes != null ? featLayerAttributes.capabilities != null ? featLayerAttributes.capabilities : "Query,Editing,Create,Update,Delete" : "Query,Editing,Create,Update,Delete", //editorTrackingInfo = editorTrackingInfo, adminLayerInfo = adminLayerInfo }; DefinitionLayer[] layers = new DefinitionLayer[1] { layer }; AddDefinition definition = new AddDefinition() { layers = layers }; string serviceEndPoint = "http://services1.arcgis.com/"; //NB: Trial Account endpoint!!!! string serviceEndPoint2 = "http://services.arcgis.com/"; string requestURL = string.Format("{0}{1}/arcgis/admin/services/{2}.FeatureServer/AddToDefinition", serviceEndPoint, _organizationID, _featureServiceCreationResponse.Name); bool b = RequestAndResponseHandler.AddToFeatureServiceDefinition(requestURL, definition, _token, txtOrgURL.Text, out formattedRequest, out jsonResponse); if (!b) { requestURL = string.Format("{0}{1}/arcgis/admin/services/{2}.FeatureServer/AddToDefinition", serviceEndPoint2, _organizationID, _featureServiceCreationResponse.Name); b = RequestAndResponseHandler.AddToFeatureServiceDefinition(requestURL, definition, _token, txtOrgURL.Text, out formattedRequest, out jsonResponse); } ShowRequestResponseStrings(formattedRequest, jsonResponse); lblSuccess.Text = b == true ? "true" : "false"; this.Cursor = Cursors.Default; }