当前位置: 首页>>代码示例>>C#>>正文


C# JsonObject.AddString方法代码示例

本文整理汇总了C#中JsonObject.AddString方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.AddString方法的具体用法?C# JsonObject.AddString怎么用?C# JsonObject.AddString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonObject的用法示例。


在下文中一共展示了JsonObject.AddString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToJsonObject

        public JsonObject ToJsonObject()
        {
            byte[] jsonBytes = Conversion.ToJson((IGeometry)this.Extent);
            JsonObject env = new JsonObject(Encoding.UTF8.GetString(jsonBytes));

            JsonObject jo = new JsonObject();
            jo.AddString("name", Name);
            jo.AddString("type", Type);
            jo.AddLong("id", ID);
            jo.AddString("description", Description);
            jo.AddJsonObject("extent", env);

            return jo;
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:14,代码来源:CustomLayerInfo.cs

示例2: ToJsonObject

        public JsonObject ToJsonObject()
        {
            JsonObject jo = new JsonObject();
            jo.AddString("name", Name);
            jo.AddLong("id", ID);

            return jo;
        }
开发者ID:geoplex,项目名称:arcgis-exporter-extension,代码行数:8,代码来源:ExportLayer.cs

示例3: ToJsonObject

 public JsonObject ToJsonObject()
 {
     JsonObject result = new JsonObject();
     result.AddString("name", Name);
     result.AddLong("id", ID);
     IRasterProps props = Raster as IRasterProps;
     result.AddLong("rows", props.Width);
     result.AddLong("columns", props.Height);
     result.AddJsonObject("extent", Conversion.ToJsonObject(props.Extent));
     return result;
 }
开发者ID:NGFieldScope,项目名称:FieldScope-SOE,代码行数:11,代码来源:QueryRasterSOE.cs

示例4: RootResHandler

        private byte[] RootResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = null;

            JsonObject result = new JsonObject();
            result.AddString("hello", "world");

            return Encoding.UTF8.GetBytes(result.ToJson());
        }
开发者ID:hanhansun,项目名称:ArcObjects.NET-Sample,代码行数:9,代码来源:SampleSOE.cs

示例5: RootResHandler

        private byte[] RootResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = null;

            JsonObject result = new JsonObject();
            result.AddString("Description", "Get raster item statistics in a mosaic dataset");
            result.AddBoolean("SupportRasterItemAccess", _supportRasterItemAccess);

            return Encoding.UTF8.GetBytes(result.ToJson());
        }
开发者ID:xyhxyw,项目名称:DeveloperSumit2014,代码行数:10,代码来源:Image_Services_SOE.cs

示例6: DoClassifyHandler

        /*
         *该方法通过纯粹的Arcobject的方式实现最大似然分类        *
         *
         * *
         */
        private byte[] DoClassifyHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties)
        {
            _logger.LogMessage(ServerLogger.msgType.infoDetailed, _soename + ".GetRasterStatistics", 8000, "request received");
            if (!_supportRasterItemAccess)
                throw new ArgumentException("The image service does not have a catalog and does not support this operation");
            responseProperties = null;

            long? objectID;
            long? classCount;
            //case insensitive
            bool found = operationInput.TryGetAsLong("objectID", out objectID);
            if (!found || (objectID == null))
                throw new ArgumentNullException("ObjectID");

            found = operationInput.TryGetAsLong("classnumber", out classCount);
            if (!found || (objectID == null))
                throw new ArgumentNullException("classnumber");
            IRasterCatalogItem rasterCatlogItem = null;
            try
            {
                rasterCatlogItem = _mosaicCatalog.GetFeature((int)objectID) as IRasterCatalogItem;
                if (rasterCatlogItem == null)
                {
                    _logger.LogMessage(ServerLogger.msgType.infoDetailed, _soename + ".GetRasterStatistics", 8000, "request finished with exception");
                    throw new ArgumentException("The input ObjectID does not exist");
                }
            }
            catch
            {
                _logger.LogMessage(ServerLogger.msgType.infoDetailed, _soename + ".GetRasterStatistics", 8000, "request finished with exception");
                throw new ArgumentException("The input ObjectID does not exist");
            }
            JsonObject result = new JsonObject();
            string outputurl = "";
            try
            {

                IRasterDataset pRasterDataSet = rasterCatlogItem.RasterDataset;

                IGeoDataset pGeo = pRasterDataSet as IGeoDataset;

                string inPath = @"D:\arcgisserver\directories\arcgisoutput\imageserver\test2_ImageServer";
                string gsgname = System.DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + ".gsg";
                string gsgPath = System.IO.Path.Combine(inPath, gsgname);

                bool bcreatesignaturefile = Classify.CreateSignaturefile(pRasterDataSet, Convert.ToInt32(classCount), gsgPath);
                if (bcreatesignaturefile)
                {
                    IMultivariateOp pMultivarateOp = new RasterMultivariateOpClass();
                    IGeoDataset pGeoDatasetResult = pMultivarateOp.MLClassify(pGeo, gsgPath, false, esriGeoAnalysisAPrioriEnum.esriGeoAnalysisAPrioriEqual, Type.Missing, Type.Missing);

                    IEnvelope pEnvelp = new EnvelopeClass();

                    string outurl = "http://localhost:6080/arcgis/rest/directories/arcgisoutput/imageserver/test2_ImageServer/";
                    pEnvelp.PutCoords(116.56075474, 40.29407147, 116.63105347, 40.34514666);
                    // string dd = ExportImage.ExportLayerImage((IRaster)pGeoDatasetResult, bbox, new string[] { "400", "400" }, outurl, fileDir);
                    outputurl = ExportImage.CreateJPEGFromActiveView((IRaster)pGeoDatasetResult, pEnvelp, outurl, inPath);
                }
            }

            catch
            {

            }
            result.AddString("url", outputurl);
            return Encoding.UTF8.GetBytes(result.ToJson());
        }
开发者ID:xyhxyw,项目名称:DeveloperSumit2014,代码行数:72,代码来源:Image_Services_SOE.cs

示例7: NumberOfTrainStationsResHandler

        private byte[] NumberOfTrainStationsResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = "{\"Content-Type\" : \"application/json\"}";

            JsonObject result = new JsonObject();
            result.AddString("numberOfTrainStations", "100");

            return Encoding.UTF8.GetBytes(result.ToJson());
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:9,代码来源:NetSimpleRESTSOEWithCapabilities.cs

示例8: editFeatureOperHandler

        private byte[] editFeatureOperHandler(NameValueCollection boundVariables,
                                                  JsonObject operationInput,
                                                      string outputFormat,
                                                      string requestProperties,
                                                  out string responseProperties)
        {
            responseProperties = null;

             // get the id of the feature to be edited	        
            object featureIdObj;
            operationInput.TryGetObject("featureId", out featureIdObj);
            int updateFeatureId = Convert.ToInt32(featureIdObj.ToString());

            object featureJSONObj;
            operationInput.TryGetObject("featureJSON", out featureJSONObj);
            JsonObject updateFeatureJSON = (JsonObject)featureJSONObj;

	        // set a filter for the specific feature
	        QueryFilter queryFilter = new QueryFilter();
            if (this.fc == null)
            {
                return createErrorObject(
                        406,
                        "Incorrect layer id provided.",
                        new String[] { "Please provide layer id of a feature layer." });
            }
            
            IClass myClass = (IClass) this.fc;
	        queryFilter.WhereClause = myClass.OIDFieldName + "=" + updateFeatureId;

	        IFeatureCursor featureCursor = this.fc.Search(queryFilter, false);

	        // attempt retrieval of the feature and check if it does exist
            IFeatureCursor myFeatureCursor = (IFeatureCursor) featureCursor;
	        IFeature updateFeature = myFeatureCursor.NextFeature();
	        if (updateFeature == null) {
	        return createErrorObject(
		        406,
		        "Incorrect feature id provided.",
		        new String[] { "No feature exists for feature id "
			        + updateFeatureId + "." });
	        }

            JsonObject response = new JsonObject();

            // edit feature
            string result = System.Text.Encoding.GetEncoding("utf-8").GetString(performEdits(updateFeature, updateFeatureJSON));
            featureCursor.Flush();
            if (result.Equals(System.Boolean.TrueString))
            {
                response.AddString("status", "success");
                response.AddString("message", "Feature " + updateFeatureId + " updated");
            }
            else
            {
                response.AddString("status", "failure");
                response.AddString("message", result);
            }

	        // send response back to client app
	        return Encoding.UTF8.GetBytes(response.ToJson());
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:62,代码来源:NetEditFeaturesRESTSOE.cs

示例9: RootResHandler

        private byte[] RootResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = null;
           
            JsonObject infoJSON = new JsonObject();
            infoJSON.AddString("name", ".Net Edit Features REST SOE");
            infoJSON.AddString("description", "This SOE adds and edits features to a selected layer in the host map service. "
                + "Note that this SOE is not designed to work with map services that have features stored in SDC data format."
                + " The \"layers\" subresource returns all layers in the map service."
                + " The \"editFeature\" operation allows editing an existing feature in the layer indicated by this SOE's layerId property.\n"
                + " The \"addFeatures\" operation allows addition of a new feature to the layer indicated by this SOE's layerId property.\n"
                + " The acceptableSchema JSON below indicates the correct schema that could be used to add/edit features. This schema belongs to the layer "
                + "selected for editing by the ArcGIS Server administrator via the SOE's layerId property. This property's value can be "
                + "modified using ArcGIS Manager.");

            // validation - ensure user has provided right layer id property value.
            if (this.layerId > this.layerInfos.Count - 1)
            {
                return createErrorObject(406, "Layer Id " + this.layerId + " is invalid.", new String[] {
				    "Acceptable layer ids are between 0 and "
					    + (layerInfos.Count - 1) + ".",
				    "Also ensure that the id points to a feature layer." });
            }

            // inform the user that edits can be done only on feature layers, if no
	        // feature layer corresponds to user-provided layerId
            if (this.editLayerInfo == null)
            {
                this.editLayerInfo = this.layerInfos.get_Element(this.layerId);
                if (!this.editLayerInfo.IsFeatureLayer)
                {
                    return createErrorObject(
                            403,
                            "The layerId property of this SOE currently points to a layer (id: "
                                + this.layerId
                                + ") that is not a feature layer.",
                            new String[] {
				            "Only feature layers can be edited by this SOE.",
				            "Modify SOE's layerId property using ArcGIS Manager or ArcGIS Desktop's Service Editor." });
                }
            }

            // Grab the fc powering the layer if its null, which means it did not get initialized in construct(), thereby 
            // suggesting that the layerId property value is incorrect.             
	        if (this.fc == null) 
            {
                // The down side of grabbing fc here is
                // that a new instance of fc is created once for every request.
                // Can't create fc in init(), since layerId property value for a
                // particular service is not necessarily available always when init() is invoked.	        
                this.fc = (IFeatureClass) this.mapServerDataAccess.GetDataSource(this.mapServerInfo.Name, this.layerId);
                if (this.fc == null)
                {
                    // if its still null, return error
                    return createErrorObject(
                        406,
                        "Incorrect layer id provided.",
                        new String[] { "Please provide layer id of a feature layer." });
                }
	        }

            infoJSON.AddString("Layer selected for editing", editLayerInfo.Name.ToString() + " (" + layerId + ")");
            JsonObject schemaJSON = getSchemaJSON();
            infoJSON.AddObject("acceptableSchema", schemaJSON);

            return Encoding.UTF8.GetBytes(infoJSON.ToJson());
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:67,代码来源:NetEditFeaturesRESTSOE.cs

示例10: ValidateData

 private byte[] ValidateData(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties)
 {
     responseProperties = null;
     string validationType;
     bool found = operationInput.TryGetString("validationType", out validationType);
     if (!found || string.IsNullOrEmpty(validationType)) throw new ArgumentNullException("validationType");
     JsonObject data;
     found = operationInput.TryGetJsonObject("data", out data);
     if (!found || (data == null)) throw new ArgumentNullException("data");
     object[] records;
     data.TryGetArray("records", out records);
     string invalidIDs = "";
     if (records.Length > 0) invalidIDs = GetInvalidIDs(records, validationType);
     JsonObject result = new JsonObject();
     result.AddString("validationType", validationType);
     result.AddString("invalidIDs", invalidIDs);
     return Encoding.UTF8.GetBytes(result.ToJson());
 }
开发者ID:andrewcottam,项目名称:IWC-ArcGIS-ServerObjectExtensions,代码行数:18,代码来源:InternationalWaterbirdCensusExtensions.cs

示例11: UpdateCheckedCount

 private byte[] UpdateCheckedCount(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties)
 {
     responseProperties = null;
     long? id;
     long? checkedVal;
     bool found = operationInput.TryGetAsLong("id", out id);
     if (!found) throw new ArgumentNullException("id");
     found = operationInput.TryGetAsLong("checked", out checkedVal);
     if (!found) throw new ArgumentNullException("checked");
     string storedProcedureName = "_IWC_UpdateChecked";
     SqlCommand cmd = new SqlCommand(storedProcedureName, sqlConn);
     cmd.CommandType = CommandType.StoredProcedure;
     SqlParameter param1 = cmd.Parameters.AddWithValue("@id", id);
     SqlParameter param2 = cmd.Parameters.AddWithValue("@checked", checkedVal);
     cmd.ExecuteNonQuery();
     JsonObject result = new JsonObject();
     result.AddString("results", "Done");
     return Encoding.UTF8.GetBytes(result.ToJson());
 }
开发者ID:andrewcottam,项目名称:IWC-ArcGIS-ServerObjectExtensions,代码行数:19,代码来源:InternationalWaterbirdCensusExtensions.cs

示例12: RootResHandler

 private byte[] RootResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
 {
     responseProperties = null;
     JsonObject result = new JsonObject();
     result.AddString("Description", "The International Waterbird Census Server Object Extensions are utility REST services for managing and querying the IWC database.");
     return Encoding.UTF8.GetBytes(result.ToJson());
 }
开发者ID:andrewcottam,项目名称:IWC-ArcGIS-ServerObjectExtensions,代码行数:7,代码来源:InternationalWaterbirdCensusExtensions.cs

示例13: GetUserSiteCodes

 private Byte[] GetUserSiteCodes(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties)
 {
     responseProperties = null;
     String userID;
     bool found = operationInput.TryGetString("userID", out userID);
     if (!found || (userID == null)) throw new ArgumentNullException("userID");
     SqlCommand cmd = new SqlCommand("_IWC_GetUserSites", sqlConn);
     cmd.CommandType = CommandType.StoredProcedure;
     SqlParameter param = cmd.Parameters.AddWithValue("@userID", userID);
     SqlDataReader reader = cmd.ExecuteReader();
     String siteCodes = null;
     if (reader.HasRows)
     {
         while (reader.Read())
         {
             siteCodes = siteCodes + "'" + reader.GetString(0) + "',";
         }
         siteCodes = siteCodes.Substring(0, siteCodes.Length - 1);
     }
     reader.Close();
     JsonObject jObject = new JsonObject();
     jObject.AddString("siteCodes", siteCodes);
     return Encoding.UTF8.GetBytes(jObject.ToJson());
 }
开发者ID:andrewcottam,项目名称:IWC-ArcGIS-ServerObjectExtensions,代码行数:24,代码来源:InternationalWaterbirdCensusExtensions.cs

示例14: GetNewSiteCode

 private byte[] GetNewSiteCode(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties)
 {
     responseProperties = null;
     string CountryCode;
     bool found = operationInput.TryGetString("CountryCode", out CountryCode);
     if (!found || string.IsNullOrEmpty(CountryCode)) throw new ArgumentNullException("CountryCode");
     string storedProcedureName = "_IWC_GetMaxSiteCode";
     SqlCommand cmd = new SqlCommand(storedProcedureName, sqlConn);
     cmd.CommandType = CommandType.StoredProcedure;
     SqlParameter param = cmd.Parameters.AddWithValue("@countryCode", CountryCode);
     SqlDataReader reader = cmd.ExecuteReader();
     string newCode = null;
     if (reader.HasRows)
     {
         while (reader.Read())
         {
             newCode = reader.GetString(0);
         }
     }
     reader.Close();
     string newnum = null;
     if (newCode != null)
     {
         newnum = Convert.ToString((Convert.ToInt32(newCode.Substring(2)) + 1));
         char pad = '0';
         newnum = newnum.PadLeft(5, pad);
     }
     if (newCode != null) newCode = CountryCode + newnum;
     JsonObject result = new JsonObject();
     result.AddString("newCode", newCode);
     return Encoding.UTF8.GetBytes(result.ToJson());
 }
开发者ID:andrewcottam,项目名称:IWC-ArcGIS-ServerObjectExtensions,代码行数:32,代码来源:InternationalWaterbirdCensusExtensions.cs

示例15: getSpeciesListForBBoxHandler

 private byte[] getSpeciesListForBBoxHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties)
 {
     responseProperties = null;
     long? txmin;
     long? txmax;
     long? tymin;
     long? tymax;
     operationInput.TryGetAsLong("txmin", out txmin);
     operationInput.TryGetAsLong("txmax", out txmax);
     operationInput.TryGetAsLong("tymin", out tymin);
     operationInput.TryGetAsLong("tymax", out tymax);
     Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory"); //open a connection to the species data table
     IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
     IWorkspace workspace = workspaceFactory.OpenFromFile("D:\\GIS Data\\Andrew\\PilotSpeciesData.gdb", 0); //TODO make this more sustainable
     IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
     IQueryDef queryDef = featureWorkspace.CreateQueryDef(); //create a query to get the data
     IQueryDef2 queryDef2 = (IQueryDef2)queryDef;
     queryDef2.Tables = "Species"; //specify the tables
     queryDef2.SubFields = "Species.tax_id,Species.friendly_name"; //specify the fields that you will return
     queryDef2.WhereClause = "tax_id IN (SELECT species_ID from PilotSpeciesData where mx between  " + txmin.ToString() + " and " + txmax.ToString() + " and my between " + tymin.ToString() + " and " + tymax.ToString() + ")"; //create the query
     queryDef2.PrefixClause = "DISTINCT";
     ICursor cursor = queryDef2.Evaluate();
     int friendly_nameIndex = cursor.FindField("Species.friendly_name");
     IRow row = null;
     String s = "";
     while ((row = cursor.NextRow()) != null) //get the resultset and iterate through the records
     {
         s = s + row.get_Value(friendly_nameIndex) + ",";
     }
     JsonObject result = new JsonObject();
     result.AddString("species", s); //write the results
     return Encoding.UTF8.GetBytes(result.ToJson()); //return the results
 }
开发者ID:andrewcottam,项目名称:eSpeciesSOEs,代码行数:33,代码来源:eSpeciesSOE.cs


注:本文中的JsonObject.AddString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。