本文整理汇总了C#中JsonObject.AddLong方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.AddLong方法的具体用法?C# JsonObject.AddLong怎么用?C# JsonObject.AddLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.AddLong方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: ToJsonObject
public JsonObject ToJsonObject()
{
JsonObject jo = new JsonObject();
jo.AddString("name", Name);
jo.AddLong("id", ID);
return jo;
}
示例3: 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.AddLong("id", ID);
jo.AddJsonObject("extent", env);
return jo;
}
示例4: CreateService
/// <summary>
/// create service type MapServer
/// </summary>
/// <returns>>True if successfully created</returns>
public bool CreateService()
{
try
{
string token = this.GenerateAGSToken();
string serviceUrl = this.urlRestAdmin + "/services/createService";
JsonObject jsonObject = new JsonObject();
jsonObject.AddString("serviceName", "Test");
//服务类型
jsonObject.AddString("type", Enum.GetName(typeof(ServiceType), ServiceType.GPServer));
jsonObject.AddString("description", "This is an example");
//不同的服务类型,其capabilities是不同的,地图服务的为Map,query和data
// jsonObject.AddString("capabilities", "Map,Query,Data");
jsonObject.AddString("capabilities","Uploads");//gp 服务的capabilities
jsonObject.AddString("clusterName", "default");
jsonObject.AddLong("minInstancesPerNode", 1);
jsonObject.AddLong("maxInstancesPerNode", 2);
jsonObject.AddLong("maxWaitTime", 60);
jsonObject.AddLong("maxStartupTime", 300);
jsonObject.AddLong("maxIdleTime", 1800);
jsonObject.AddLong("maxUsageTime", 600);
jsonObject.AddLong("recycleInterval", 24);
jsonObject.AddString("loadBalancing", Enum.GetName(typeof(LoadBalancing), LoadBalancing.ROUND_ROBIN));
jsonObject.AddString("isolationLevel", Enum.GetName(typeof(IsolationLevel), IsolationLevel.HIGH));
JsonObject jsonObjectProperties = new JsonObject();
// see for a list complete http://resources.arcgis.com/en/help/server-admin-api/serviceTypes.html
jsonObjectProperties.AddLong("maxBufferCount", 100); // optional 100
jsonObjectProperties.AddString("virtualCacheDir", this.urlRestServer + "/arcgiscache"); // optional
jsonObjectProperties.AddLong("maxImageHeight", 2048); // optional 2048
jsonObjectProperties.AddLong("maxRecordCount", 1000); // optional 500
//10.1中服务是通过msd的形式发布的,所以创建地图服务时候将mxd转换成msd的形式,创建msd的形式而其他服务的数据发布形式,参考上面的链接
// jsonObjectProperties.AddString("filePath", @"C:\AvGis\Test\mappa\UTM_ReteFognaria.msd"); //地图服务 required
jsonObjectProperties.AddString( "toolbox",@"d:\Buffer.tbx");//gp服务使用的是路径创建gp服务的路径
jsonObjectProperties.AddLong("maxImageWidth", 2048); // optional 2048
jsonObjectProperties.AddBoolean("cacheOnDemand", false); // optional false
jsonObjectProperties.AddString("virtualOutputDir", this.urlRestServer + "/arcgisoutput");
jsonObjectProperties.AddString("outputDir", @"C:\arcgisserver\directories\arcgisoutput");
jsonObjectProperties.AddString("jobsDirectory", @"C:\arcgisserver\directories\arcgisjobs"); // required
jsonObjectProperties.AddString("supportedImageReturnTypes", "MIME+URL"); // optional MIME+URL
jsonObjectProperties.AddBoolean("isCached", false); // optional false
jsonObjectProperties.AddBoolean("ignoreCache", false); // optional false
jsonObjectProperties.AddBoolean("clientCachingAllowed", false); // optional true
jsonObjectProperties.AddString("cacheDir", @"C:\arcgisserver\directories\arcgiscache"); // optional
jsonObject.AddJsonObject("properties", jsonObjectProperties);
string result = this.GetResult(serviceUrl, "service=" +HttpUtility.UrlEncode(jsonObject.ToJson()) + "&f=json&token=" + token);
return this.HasSuccess(result);
}
catch
{
return false;
}
}
示例5: DescribeLayersHandler
private byte[] DescribeLayersHandler(NameValueCollection boundVariables,
JsonObject operationInput,
string outputFormat,
string requestProperties,
out string responseProperties)
{
responseProperties = null;
JsonObject tResult = new JsonObject();
tResult.AddLong("AvailableLayerCount", m_ExtractableParams.Count);
JsonObject tLayersJson = new JsonObject();
foreach (ExtractionLayerConfig layer in m_ExtractableParams){
//int id = layer.LayerID;
string lyrName = layer.LayerName;
string requestParameter = layer.ParamName;
string extractionType = layer.ExtractionType.ToString();
JsonObject tLayerJson = new JsonObject();
//tLayerJson.AddLong("LayerId", id);
tLayerJson.AddString("LayerName",lyrName);
tLayerJson.AddString("LayerDescription", layer.LayerDescription);
tLayerJson.AddString("ExtractionType", extractionType);
if (layer.HasCategories)
{
IFeatureClass tLayerAsFc = (IFeatureClass)layer.LayerDataset;
string tCatName = tLayerAsFc.Fields.get_Field(layer.CategoryField).Name;
tLayerJson.AddString("CategoryField", tCatName);
}
tLayersJson.AddObject(requestParameter,tLayerJson);
}
tResult.AddObject("Extractions", tLayersJson);
byte[] tOutput = System.Text.Encoding.UTF8.GetBytes(tResult.ToJson());
return tOutput;
}
示例6: GetErrorResponse
private JsonObject GetErrorResponse(string message)
{
var error = new JsonObject();
error.AddLong("code", 0);
error.AddString("message", message);
var response = new JsonObject();
response.AddJsonObject("error", error);
return response;
}
示例7: PropertiesResHandler
private byte[] PropertiesResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
{
responseProperties = "{\"Content-Type\" : \"application/json\"}";
JsonObject result = new JsonObject();
result.AddString("layers", this.layerType);
result.AddString("returnFormat", this.returnFormat);
result.AddLong("maxNumFeatures", this.maxNumFeatures);
result.AddBoolean("isEditable", this.isEditable);
return Encoding.UTF8.GetBytes(result.ToJson());
}
示例8: PostData
private byte[] PostData(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties)
{
responseProperties = null;
string userID;
bool found = operationInput.TryGetString("userID", out userID);
if (!found || string.IsNullOrEmpty(userID)) throw new ArgumentNullException("userID");
JsonObject data;
found = operationInput.TryGetJsonObject("data", out data);
if (!found || (data == null)) throw new ArgumentNullException("data");
object[] records;
data.TryGetArray("records", out records);
int recordsPosted = -1;
if (records.Length > 0) recordsPosted = PostRecords(records, userID);
JsonObject result = new JsonObject();
result.AddLong("recordsPosted", recordsPosted);
return Encoding.UTF8.GetBytes(result.ToJson());
}
开发者ID:andrewcottam,项目名称:IWC-ArcGIS-ServerObjectExtensions,代码行数:17,代码来源:InternationalWaterbirdCensusExtensions.cs
示例9: backgroundWorker1_DoWork
/// <summary>
/// Build Cache Backgroud worker
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
int size = int.Parse(this.tbxSize.Text);
IFeatureClass fc_poi = m_fcName.Open() as IFeatureClass;
IGeoDataset ds_poi = fc_poi as IGeoDataset;
int xmin = (int)Math.Floor(ds_poi.Extent.XMin);
int ymin = (int)Math.Floor(ds_poi.Extent.YMin);
int xmax = (int)Math.Ceiling(ds_poi.Extent.XMax);
int ymax = (int)Math.Ceiling(ds_poi.Extent.YMax);
List<JsonObject> ls_fields_cache = new List<JsonObject>();
if(!(fc_poi.Extension is IAnnotationClassExtension))
{
for (int i = 0; i < fc_poi.Fields.FieldCount; i++)
{
IField field = fc_poi.Fields.get_Field(i);
JsonObject js_f = new JsonObject();
js_f.AddString("name", field.Name);
js_f.AddString("type", Enum.GetName(typeof(esriFieldType), field.Type));
js_f.AddString("alias", field.AliasName);
if (field.Type == esriFieldType.esriFieldTypeString)
{
js_f.AddString("length", field.Length.ToString());
}
else
{
js_f.AddString("length", "");
}
ls_fields_cache.Add(js_f);
}
}
IDatabase client = m_redis.GetDatabase();
int grid_id=0;
string ns = "poi:" + this.tbxCacheName.Text+":";
for (int y = ymin; y <= ymax; y += size)
{
for (int x = xmin; x <= xmax; x += size)
{
List<String> str_poi_grid = new List<String>();
List<JsonObject> ls_features = new List<JsonObject>();
//String str_response = client.StringGet(ns+"response");
//JsonObject response = new JsonObject(str_response);
JsonObject response = new JsonObject();
IEnvelope box = new EnvelopeClass();
box.XMin = x ;
box.YMin = y ;
box.XMax = x +size;
box.YMax = y +size;
ISpatialFilter filter_poi = new SpatialFilterClass();
filter_poi.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
filter_poi.Geometry = box;
filter_poi.SubFields = "*";
IFeatureCursor cur_poi = fc_poi.Search(filter_poi, true);
IFeature fea_poi = cur_poi.NextFeature();
while (fea_poi != null)
{
JsonObject js_fea = new JsonObject();
if (!(fea_poi is IAnnotationFeature))
{
JsonObject js_attributes = new JsonObject();
int i = 0;
foreach (JsonObject js_field in ls_fields_cache)
{
object value = fea_poi.get_Value(i);
string fieldtype;
js_field.TryGetString("type", out fieldtype);
string fieldname;
js_field.TryGetString("name", out fieldname);
#region
if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeString))
{
js_attributes.AddString(fieldname, value.ToString());
}
else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeOID))
{
js_attributes.AddLong(fieldname, long.Parse(value.ToString()));
}
else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeInteger))
{
if (value.ToString() == "")
{
value = 0;
}
js_attributes.AddLong(fieldname, long.Parse(value.ToString()));
}
else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSmallInteger))
{
if (value.ToString() == "")
{
value = 0;
}
js_attributes.AddLong(fieldname, long.Parse(value.ToString()));
}
//.........这里部分代码省略.........
示例10: BuildMeta
/// <summary>
/// Build Meta Info
/// </summary>
private void BuildMeta()
{
IFeatureClass fc_poi = m_fcName.Open() as IFeatureClass;
IGeoDataset ds_poi = fc_poi as IGeoDataset;
int xmin = (int)Math.Floor(ds_poi.Extent.XMin);
int ymin = (int)Math.Floor(ds_poi.Extent.YMin);
int xmax = (int)Math.Ceiling(ds_poi.Extent.XMax);
int ymax = (int)Math.Ceiling(ds_poi.Extent.YMax);
int size = int.Parse(this.tbxSize.Text);
int step = (int)Math.Ceiling((xmax - xmin) * 1.0 / size);
string ns = "poi:" + this.tbxCacheName.Text + ":";
IDatabase client = m_redis.GetDatabase();
client.StringSet(ns + "size", size.ToString());
client.StringSet(ns + "xmin", xmin.ToString());
client.StringSet(ns + "ymin", ymin.ToString());
client.StringSet(ns + "xmax", xmax.ToString());
client.StringSet(ns + "ymax", ymax.ToString());
client.StringSet(ns + "step", step.ToString());
JsonObject response = new JsonObject();
List<JsonObject> ls_fields_cache = new List<JsonObject>();
for (int i = 0; i < fc_poi.Fields.FieldCount; i++)
{
IField field = fc_poi.Fields.get_Field(i);
JsonObject js_f = new JsonObject();
js_f.AddString("name", field.Name);
js_f.AddString("type", Enum.GetName(typeof(esriFieldType), field.Type));
js_f.AddString("alias", field.AliasName);
if (field.Type == esriFieldType.esriFieldTypeString)
{
js_f.AddString("length", field.Length.ToString());
}
else
{
js_f.AddString("length", "");
}
ls_fields_cache.Add(js_f);
}
response.AddArray("fields", ls_fields_cache.ToArray());
if (fc_poi.ShapeType == esriGeometryType.esriGeometryPoint)
{
response.AddString("geometryType", "esriGeometryPoint");
}
else if (fc_poi.ShapeType == esriGeometryType.esriGeometryPolyline)
{
response.AddString("geometryType", "esriGeometryPolyline");
}
else if (fc_poi.ShapeType == esriGeometryType.esriGeometryPolygon)
{
response.AddString("geometryType", "esriGeometryPolygon");
}
IGeoDataset gds_poi = fc_poi as IGeoDataset;
JsonObject js_sr = new JsonObject();
js_sr.AddLong("wkid", gds_poi.SpatialReference.FactoryCode);
response.AddJsonObject("spatialReference", js_sr);
client.StringSet(ns + "response", response.ToJson());
client.SetAdd("poi:caches", this.tbxCacheName.Text);
}
示例11: ToJsonObject
public JsonObject ToJsonObject()
{
JsonObject result = new JsonObject();
if (DisplayFieldName != null) {
result.AddString("displayFieldName", DisplayFieldName);
}
if (Fields.Count > 0) {
JsonObject[] fields = new JsonObject[Fields.Count];
for (int i = 0; i < Fields.Count; i += 1) {
IField field = Fields[i];
JsonObject fjson = new JsonObject();
fjson.AddString("name", field.Name);
fjson.AddString("alias", field.AliasName);
fjson.AddString("type", FIELD_TYPE_NAMES[(int)field.Type]);
fjson.AddLong("length", field.Length);
fields[i] = fjson;
}
result.AddArray("fields", fields);
}
if (GeometryType != esriGeometryType.esriGeometryAny) {
result.AddString("geometryType", GEOMETRY_TYPE_NAMES[(int)GeometryType]);
}
if (Features.Count > 0) {
JsonObject[] features = new JsonObject[Features.Count];
for (int i = 0; i < Features.Count; i += 1) {
features[i] = Features[i].ToJsonObject();
}
result.AddArray("features", features);
}
return result;
}