Exemplo n.º 1
0
        private void UpdateData()
        {
            FieldInfo[] fldInfos = new FieldInfo[1]{new FieldInfo()
              {
            isEditable = false,
            stringFieldOption = "textbox",
            tooltip = "Field values pertaining to unique color ranges",
            label = "Unique Values",
            visible = true,
            fieldname = cboFields.Text
              }};

              UpdateLayer layer = new UpdateLayer()
              {
            id = 0,
            popupInfo = new PopupInfo()
            {
              showAttachments = false,
              fieldInfos = fldInfos,
              description = null,
              label = "Unique value renderer",
            }
              };

              Extent extent = new Extent()
              {
            xmin = -14999999.999999743,
            ymin = 1859754.5323447795,
            xmax = -6199999.999999896,
            ymax = 7841397.327701188,
            spatialReference = new SpatialReference() { wkid = 102100 },
              };

              Part part = new Part()
              {
            extent = extent,
            frameids = new int[] { 0 }
              };

              AnalysisInfo analysisInfoTEST = new AnalysisInfo()
              {
            toolName = "",
            jobParams = new JobParams()
            {
              InputLayer = new InputLayer()
              {//TODO input layer endpoint
            url = _arcgGISOnlineFeatureServiceURL + "/0", //"http://services.arcgis.com/q7zPNeKmTWeh7Aor/arcgis/rest/services/nyvoters_Party/FeatureServer/0",
            serviceToken = _arcgGISOnlineOrganizationToken
              },
              OutputName = new OutputName()
              {
            serviceProperties = new ServiceProperty()
            {
              name = "Unique_Values"
            },
            itemProperties = new ItemProperties()
            {
              itemID = _featureServiceCreationResponse.ServiceItemId,
            }
              },
              context = new Context()
              {
            extent = extent,
            parts = new Part[1] { part }
              }
            }
              };

              Update update = new AGOLRestHandler.Update()
              {
            title = txtFeatureServiceName.Text,
            description = string.Empty,
            tags = "",
            extent = extent,
            thumbnailURL = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/export?size=200,133&bboxSR=4326&format=png24&f=image&bbox=-161.697,-79.691,161.697,85",
            typeKeywords = "ArcGIS Server,Data,Feature Access,Feature Service,jobUrl:http://analysis.arcgis.com/arcgis/rest/services/tasks/GPServer/CreateBuffers/jobs/j6a67709cac1e4568a26d32568d01a695,Service,Hosted Service",
            text = new AGOLRestHandler.Text()
            {
              layers = new UpdateLayer[1] { layer },
              analysisInfo = analysisInfoTEST
            }
              };

              //
              string url = "http://startups.maps.arcgis.com/sharing/content/users/edan/items/" + _featureServiceCreationResponse.ServiceItemId + "/update";
              string jsontest = RequestAndResponseHandler.UpdateFeatureService(update, url);

              btnUpdate.Enabled = false;
        }
Exemplo n.º 2
0
        /// <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+QAAB3VJREFUeF7tmPlTlEcexnve94U5mANQbgQSbgiHXHINlxpRIBpRI6wHorLERUmIisKCQWM8cqigESVQS1Kx1piNi4m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SG2LkyZex1uO1mZM9lKem9Tx9jjY5iNEYo0bKMhn7ZAu0r6H5PpLXCAq0rKJClSjSGynE/QIkrQYqBPe6S2X+AJsY2Ped6iWZk6RlL0c2r5szofRsO9R5S1IfQLRCpQL1aifoYFerpsbkuTImaUJXuXIDiH6/Ys8vm3Mg8L2i20YqsO7fItKLcSXyn0kXccclVqv3MS6at9JU/Ox+ouns+SF6Z4cSupz7l8+z1ucs7LF1AQjOdxfGZzmx8Iu1TRcfnrioICAQEAgIBgYBAQCAgEBAICAQEAgIBgYBAQCAgEBAICAQEAv8H44b/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;
        }
Exemplo n.º 3
0
        private void AddDefinitionToFeatureService()
        {
            /*
               * The main demonstration code of this project.
               * Iterates through the DataGridView records, creating the fields and ensuring that the esri field types for each are correct.
               * */
              //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;

              FeatureLayerAttributes featLayerAttributes = new FeatureLayerAttributes();

              this.Cursor = Cursors.WaitCursor;

              if (featLayerAttributes.extent != null)
            extent = featLayerAttributes.extent;
              else
              {
            extent = new Extent()
            {
              xmin = Convert.ToDouble(txtXMin.Text),
              ymin = Convert.ToDouble(txtYMin.Text),
              xmax = Convert.ToDouble(txtXMax.Text),
              ymax = Convert.ToDouble(txtYMax.Text),
              spatialReference = new SpatialReference() { wkid = Convert.ToInt32(txtSpatialRef.Text) },
            };
              }

            symbol = new Symbol()
            {
              type = "esriPMS",
              url = "RedSphere.png",
              imageData = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQBQYWludC5ORVQgdjMuNS4xTuc4+QAAB3VJREFUeF7tmPlTlEcexnve94U5mANQbgQSbgiHXHINlxpRIBpRI6wHorLERUmIisKCQWM8cqigESVQS1Kx1piNi4mW2YpbcZONrilE140RCTcy3DDAcL/zbJP8CYPDL+9Ufau7uqb7eZ7P+/a8PS8hwkcgIBAQCAgEBAICAYGAQEAgIBAQCAgEBAICAYGAQEAgIBAQCDx/AoowKXFMUhD3lQrioZaQRVRS+fxl51eBTZUTdZ41U1Rox13/0JF9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3Mg8L2i20YqsO7fItKLcSXyn0kXccclVqv3MS6at9JU/Ox+ouns+SF6Z4cSupz7l8+z1ucs7LF1AQjOdxfGZzmx8Iu1TRcfnrioICAQEAgIBgYBAQCAgEBAICAQEAgIBgYBAQCAgEBAICAQEAv8H44b/6ZiGvGAAAAAASUVORK5CYII=",
              contentType = "image/png",
              color = null,
              width = 15,
              height = 15,
              angle = 0,
              xoffset = 0,
              yoffset = 0
            };

            renderer = new Renderer()
            {
              type = "simple",
              symbol = symbol,
              label = "",
              description = ""
            };

            drawingInfo = new DrawingInfo()
            {
              renderer = renderer,
              labelingInfo = null
            };

            List<object> fieldList = new List<object>();
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
              DataGridViewCell cell = dataGridView1.Rows[i].Cells[1];
              if (cell.Value.ToString() == "Double")
              {
            FieldDouble field2 = new FieldDouble()
            {
              name = dataGridView1.Rows[i].Cells[0].Value.ToString(),
              type = "esriFieldTypeDouble",
              alias = dataGridView1.Rows[i].Cells[0].Value.ToString(),
              sqlType = "sqlTypeFloat",
              nullable = true,
              editable = true,
              domain = null,
              defaultValue = null
            };
              }
              else if (cell.Value.ToString() == "string")
              {
            FieldString field3 = new FieldString()
            {
              name = dataGridView1.Rows[i].Cells[0].Value.ToString(),
              type = "esriFieldTypeString",
              alias = dataGridView1.Rows[i].Cells[0].Value.ToString(),
              sqlType = "sqlTypeNVarchar",
              length = 256,
              nullable = true,
              editable = true,
              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 = fieldList.ToArray();

              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 = Convert.ToInt32(txtSpatialRef.Text)
            }
              };

              layer = new DefinitionLayer()
              {
            currentVersion = featLayerAttributes != null ? featLayerAttributes.currentVersion : 10.11,
            id = 0,
            name = featLayerAttributes != null ? featLayerAttributes.name != null ? featLayerAttributes.name : "BrewsDownload" : "BrewsDownload",
            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 != true ? 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 = drawingInfo,
            allowGeometryUpdates = featLayerAttributes != null ? featLayerAttributes.allowGeometryUpdates != true ? 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 = featLayerAttributes != null ? featLayerAttributes.maxRecordCount != 0 ? featLayerAttributes.maxRecordCount : 2000 : 2000,
            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/";
              string serviceEndPoint2 = "http://services.arcgis.com/";
              bool b = RequestAndResponseHandler.AddToFeatureServiceDefinition(serviceEndPoint + _organizationID + "/arcgis/admin/services/" + _featureServiceCreationResponse.Name + ".FeatureServer/AddToDefinition", definition, _token, txtOrg.Text);

              if (!b)
            b = RequestAndResponseHandler.AddToFeatureServiceDefinition(serviceEndPoint2 + _organizationID + "/arcgis/admin/services/" + _featureServiceCreationResponse.Name + ".FeatureServer/AddToDefinition", definition, _token, txtOrg.Text);

              lblSuccess.Text = b == true ? "true" : "false";

              Update();

              this.Cursor = Cursors.Default;
        }