arcgis10.12发布地图服务设置。

ArcGIS Server 10.2 WEB开发问题_百度知道
ArcGIS Server 10.2 WEB开发问题
1:已经有a.gdb文件夹
a.mxd文件2:如何发布地图,3:并且可以在web页面 描点(10个银行的点)4:web页面点击按钮(所有银行),则显示 2 步骤所添加的所有点。5:能简单描述一下流程吗?简单易懂的最好。谢谢!
发布已经能发布成server,页面也可以调用底图。主要是 3步,4步,不太懂
提问者采纳
地图是在arcmap中发布的,首先你要有arcserver才能发布地图。至于你说的描点,应该是在地图上描点吧。然后你制作好的web页面,能点击你这些点是不?具体没懂你的第三点和第四点的问题。我一般是在地图上描点,然后在页面只要做一些操作就行。什么单机高亮啊,什么路劲规划啊。什么的
我的意思是,在页面录入一个银行的点,点击确定,则这个点保存起来。然后在页面有个按钮点击,显示银行,录入的所有点则显示出来。
这样啊,那就是在web页面上加点要素咯,至于后面那个的问题,就是你所有录入的点高亮显示咯。
点,是如何存储,及如何显示。主要是这两个弄不懂。
。var tubiaoLayer = new esri.layers.GraphicsLayer();var ptext = new esri.geometry.Point(你点击的横坐标,纵坐标,new esri.SpatialReference({wkid:2431}));var pgic = new esri.Graphic(ptext,symboltext);tubiaoLayer.add(pgic);map.addLayer(tubiaoLayer );这样你就添加点了,不过这个是用javascript开发的。。。显示:其实显示,就是把你所有的点重新,画在地图上,颜色区分就好了
这个是 在地图上 添加一个点,如何存储 这个点,存经度纬度?然后查询,查询这个经度纬度,在地图上显示吗?如果点很多 点击查询银行,一个点一个点循环画在地图上?会不会很卡?
js的话,不会很卡的,还是比较快的。地图会在初次初始化的时候比较卡。你这个点是要修改地图吗?我没有使用过经度纬度,我一般都是使用坐标的。
修改地图是什么意思,我只是想在地图上
标注一个点,然后再把点 显示出来。存坐标 也是 X Y两个值吧,显示根据 X , Y 定位,然后画点?
对的,我就是根据那x,y画点要素,你可以用js把这些点要素存起来。我也没有试过在客户端改地图,我还以为你是要在客户端改地图呢。
哦,这样子,我就是担心,循环画点会很慢。改地图我也不会弄,我想如果
添加1个图层然后在图层上标注点,页面引用这个图层就可以了,也不用循环画点了。。就是不知道怎么弄。
只要你不手动写代码去清除这个图层上的内容或者不手动去清除map上的内容,图层上的内容是不会修改的。还有就是循环画点还是蛮快的,这个是在客服端完成的,没有调用server端,不会很慢,我做路劲规划都还蛮快的。
那是不是不需要创建企业地理数据库,我没弄明白。我创建个普通业务数据库,与页面 传递坐标就可以了吧。
提问者评价
其他类似问题
按默认排序
其他1条回答
1:双击 a.mxd文件 打开后2:菜单栏 file-&share as -& service.. 后面 点击分析 、发布3:描点功能 可以用数据库存储和页面交互 或者 用featurelayer 可以描点4:点点击用graphic加click事件 或者 graphicslayer 的infoWindowRenderer
页面,点击我可以 描点,就是 ,点是如何存储,及如何显示问题。能具体说说吗
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁ArcGIS Help 10.2 -
使用默认工作目录文件夹和默认地理数据库
使用默认工作目录文件夹ArcMap 中的主要工作空间之一就是各地图文档的默认工作目录文件夹,即存储地图文档的文件夹位置。在 ArcMap 中,“默认工作目录”文件夹在默认情况下可用于保存结果、存储新建数据集和访问基于文件的信息。它是用于将新建图层添加到 ArcMap,和存储在执行编辑与地理处理过程中创建的新数据集的初始位置。这也同样适用于非空间数据。如果将页面布局导出为 PDF,则默认位置将是地图的默认工作目录位置(地图文档的工作空间文件夹)。 设置和更改地图的“默认工作目录”文件夹您可以随时将地图文档复制到新的文件夹位置,此位置将成为地图的默认工作目录文件夹。您可以使用它组织 ArcGIS 信息。例如,通用文件夹可用于保存大量的相关地图文档,这些地图文档共享公用的默认工作目录文件夹。您可以通过单击目录 窗口菜单中的默认工作目录按钮 访问目录 窗口中地图的默认工作目录文件夹。可以通过单击选项按钮 ,然后选择目录选项对话框中的默认工作目录文件夹选项卡,来更改默认工作目录文件夹位置。输入将要用于所有新地图文档的新默认工作目录位置。使用默认地理数据库 每个地图文档都有一个默认地理数据库,作为地图空间内容的本地位置。此位置可用于添加数据集和保存各种编辑操作和地理处理操作生成的结果数据集。例如,从图层中导出要素时,除非另外指定,否则数据会自动保存到地图的默认地理数据库中。默认地理数据库与“地理处理环境”的“当前工作空间”始终一致,因此工具或模型的所有输出内容都将保存到此默认位置。 创建新地图文档时,系统将提示您选择默认地理数据库。只要您拥有写访问权限,就可以将任何地理数据库设置为默认地理数据库。您可能拥有一个在 DBMS(例如,SQL Server 或 Oracle)中进行存储或管理的共享地理数据库。默认地理数据库可以是文件地理数据库、个人地理数据库、个人 SQL Server 地理数据库或企业级地理数据库。 不必为文档手动指定默认地理数据库。默认情况下,ArcGIS 将会在 ArcGIS 默认工作目录文件夹中自动创建一个名为 Default.gdb 的文件地理数据库。ArcMap、ArcScene 和 ArcGlobe 将使用此地理数据库作为新建文档或已打开的现有文档(10 版之前)的默认地理数据库,除非您指明您要使用其他地理数据库作为默认数据库。可通过目录 窗口菜单访问默认地理数据库 ,并且添加数据 和另存为 对话框中还提供了访问默认地理数据库的快捷方式,因此,即使您已导航到系统的其他位置,也可以快速返回到地图的默认地理数据库。设置默认地理数据库确保您具有访问权限。必要时,为企业级地理数据库建立数据库连接。如果要创建新文件地理数据库,可以在目录 窗口中创建一个新的地理数据库作为地图的默认地理数据库。导航至树视图中所需的地理数据库,并单击使其高亮显示。右键单击此地理数据库,在其快捷菜单中单击设为默认地理数据库。注:设为默认地理数据库选项在从目录 窗口中的“数据库服务器”结点 访问的地理数据库的快捷菜单上不可用。要使用此功能,请从“数据库连接”结点
连接到这些地理数据库。您还可以在启动 ArcMap 时显示的启动 对话框中设置默认地理数据库的路径:创建或打开地图文档后,可通过目录 窗口(右键单击要用作当前文档的地理数据库,然后选择设为默认地理数据库),或通过地图文档属性对话框(文件 & 地图文档属性),来随时更改默认地理数据库。1864人阅读
ArcGIS Engine 10.2 如何发布服务
ArcGIS Engine的代码不能直接将MXD地图文档作为数据源进行发布,如果要发布的话,需要用ArcMap将MXD转成MSD,然后使用转换成功的MSD文档进行发布,代码如下:
public void
Publish(string
host,string
username,string
password,& string
service, string
msdDocument, string
outputDir)
&&&&&&&&&&& //IAGSServerConnectionFactory3 pConnectionFactory = new AGSServerConnectionFactoryClass();
&&&&&&&&&&& ////admin connection file works fine, tested in ArcCatalog on the same server
&&&&&&&&&&& //IAGSServerConnection4 server = pConnectionFactory.OpenFromFile(@&e:\admin-connection.ags&, 0) as IAGSServerConnection4;
&&&&&&&&&&& //&&&& IAGSServerConnectionAdmin pAGSServerConnectionAdmin = server as IAGSServerConnectionA
&&&&&&&&&&& IPropertySet
propertySet = new
PropertySetClass();
&&&&&&&&&&& propertySet.SetProperty(&url&,
&&&&&&&&&&& propertySet.SetProperty(&ConnectionMode&,
esriAGSConnectionMode.esriAGSConnectionModeAdmin);
&&&&&&&&&&& propertySet.SetProperty(&ServerType&,
esriAGSServerType.esriAGSServerTypeDiscovery);
&&&&&&&&&&& propertySet.SetProperty(&user&,
username);
&&&&&&&&&&& propertySet.SetProperty(&password&,
password);
&&&&&&&&&&& propertySet.SetProperty(&ALLOWINSECURETOKENURL&,
true); //设置为false会弹出一个警告对话框
&&&&&&&&&&& IAGSServerConnectionName3
pConnectName = new
AGSServerConnectionNameClass()
as IAGSServerConnectionName3;//10.1新增接口
&&&&&&&&&&& pConnectName.ConnectionProperties =
propertySet;
&&&&&&&&&&& IAGSServerConnectionAdmin
pAGSAdmin = ((IName)pConnectName).Open()
as IAGSServerConnectionAdmin;
&&&&&&&&&&& IAGSServerConnectionAdmin
pAGSServerConnectionAdmin =
pAGSAdmin as IAGSServerConnectionAdmin;
&&&&&&&&&&& IServerObjectAdmin
pServerObjectAdmin =
pAGSServerConnectionAdmin.ServerObjectAdmin;
&&&&&&&&&&& IServerObjectConfiguration5
pConfiguration = (IServerObjectConfiguration5)pServerObjectAdmin.CreateConfiguration();
&&&&&&&&&&& //Set the general configuration settings
&&&&&&&&&&& pConfiguration.Name =
&&&&&&&&&&& pConfiguration.TypeName =
&MapServer&;
&&&&&&&&&&& pConfiguration.TargetCluster =
&default&;
&&&&&&&&&&& pConfiguration.StartupType =
esriStartupType.esriSTAutomatic;
&&&&&&&&&&& pConfiguration.IsolationLevel =
esriServerIsolationLevel.esriServerIsolationHigh;
&&&&&&&&&&& pConfiguration.IsPooled =
&&&&&&&&&&& pConfiguration.Description =
&Modsim Map Output&;
&&&&&&&&&& // pConfiguration.LoadBalancing = esriLoadBalancing.esriLoadBalancingN//没有集群的话可以不用设置
&&&&&&&&&&& pConfiguration.MinInstances = 1;
&&&&&&&&&&& pConfiguration.MaxInstances = 15;
&&&&&&&&&&& pConfiguration.WaitTimeout = 60;
&&&&&&&&&&& pConfiguration.UsageTimeout = 600;
&&&&&&&&&&& pConfiguration.IdleTimeout = 1800;
&&&&&&&&&&& //Set the configuration properties of the MapServer
&&&&&&&&&&& IPropertySet
pProps = pConfiguration.Properties;
&&&&&&&&&&& pProps.SetProperty(&FilePath&,
msdDocument);
&&&&&&&&&&& pProps.SetProperty(&OutputDir&,
outputDir);
&&&&&&&&&&& pProps.SetProperty(&MaxImageHeight&,
&&&&&&&&&&& pProps.SetProperty(&MaxRecordCount&,
&&&&&&&&&&& pProps.SetProperty(&MaxBufferCount&,
&&&&&&&&&&& pProps.SetProperty(&MaxImageWidth&,
&&&&&&&&&&& pConfiguration.Properties =
&&&&&&&&&&& //MIME+URL (virtual directory)
&&&&&&&&&&& IEnumServerDirectory
dirs = pServerObjectAdmin.GetServerDirectories();
&&&&&&&&&&& dirs.Reset();
&&&&&&&&&&& IServerDirectory
serverDir = dirs.Next();
&&&&&&&&&&& while (serverDir !=
&&&&&&&&&&& {
&&&&&&&&&&&&&&& if (((IServerDirectory2)serverDir).Type ==
esriServerDirectoryType.esriSDTypeOutput)
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& pProps.SetProperty(&OutputDir&,
serverDir.Path);
&&&&&&&&&&&&&&&&&&& pProps.SetProperty(&VirtualOutputDir&,
serverDir.URL);
&&&&&&&&&&&&&&&&&&& break;
&&&&&&&&&&&&&&&&&& // gp.AddMessage(&[DEBUG] Outputpath: & + serverDir.Path + & || Virtual: & + serverDir.URL);
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& serverDir =
dirs.Next();
&&&&&&&&&&& }
&&&&&&&&&&& //Set the info segment properties
&&&&&&&&&&& IPropertySet
info = pConfiguration.Info;
&&&&&&&&&&& info.SetProperty(&WebEnabled&,
&&&&&&&&&&& info.SetProperty(&WebCapabilities&,
&Map,Query,Data&);
&&&&&&&&&&& pConfiguration.Info =
&&&&&&&&&&& //Set the recycle properties of the MapServer object
&&&&&&&&&&& IPropertySet
recycle = pConfiguration.RecycleProperties;
&&&&&&&&&&& recycle.SetProperty(&StartTime&,
&1:00 AM&);
&&&&&&&&&&& recycle.SetProperty(&Interval&,
&&&&&&&&&&& pConfiguration.RecycleProperties =
&&&&&&&&&&& //Add the configuration to the server
&&&&&&&&&&& pServerObjectAdmin.AddConfiguration(pConfiguration);
&&&&&&&&&&& pServerObjectAdmin.StartConfiguration(service,
&MapServer&);
使用中的发布地图文档
ArcGIS 10.1 在发布服务的时候其实是按照下面的步骤来的,如果认真观察过也不难得出:
l& 将MXD文档转成sddraft文件;
l& 将sddraft文件转成sd文件;
l& 将sd文件上传到ArcGIS for Server中
既然这个过程已经知道了,那么就可以通过Python按照这个流程来自动化的完成服务的发布:
import arcpy
# define local variables
wrkspc = 'C:/Project/'
mapDoc = arcpy.mapping.MapDocument(wrkspc +
'counties.mxd')
con = r'GIS Servers\arcgis on MyServer_6080 (admin).ags'
'Counties'
sddraft = wrkspc + service +
'.sddraft'
sd = wrkspc + service +
# create service definition draft
arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service,
'ARCGIS_SERVER', con, True, None)
# analyze the service definition draft
analysis = arcpy.mapping.AnalyzeForSD(sddraft)
# stage and upload the service if the sddraft analysis did not contain errors
if analysis['errors'] == {}:
&&& # Execute StageService
&&& arcpy.StageService_server(sddraft, sd)
&&& # Execute UploadServiceDefinition
&&& arcpy.UploadServiceDefinition_server(sd, con)
&&& # if the sddraft analysis contained errors, display them
&&& print analysis['errors']
可以将上面的脚本创建为一个tbx文件,然后在ArcGIS Engine中通过GP来实现服务的发布.
其实Esri在官网上发布了一个tbx里面就包含了对server服务管理的功能(有兴趣的可以下载,文档所在的目录下也包含了):
使用发布文档
ArcGIS for Server 10.1 增加了Admin API,那么,所谓的Admin API 其实就是一一http请求的方法,这些方法包含了对Server的管理,下面为Admin API 的代码:
ServerAPIAdmin.ArcGIS.Rest
System.Collections;
System.Collections.Generic;
System.IO;
System.Linq;
System.Net;
System.Text;
System.Web;
ESRI.ArcGIS.SOESupport;
&&& ///&summary&
&&& /// tipi di servizio arcgis server (mappa la tabella servizio tipo)
&&& ///&/summary&
&&& public
enum ServiceType
&&&&&&& MapServer,
&&&&&&& GeocodeServer,
&&&&&&& SearchServer,
&&&&&&& IndexingLauncher,
&&&&&&& IndexGenerator,
&&&&&&& GeometryServer,
&&&&&&& GeoDataServer,
&&&&&&& GPServer,
&&&&&&& GlobeServer,
&&&&&&& ImageServer
&&& ///&summary&
&&& /// Load Balancing
&&& ///&/summary&
&&& public
enum LoadBalancing
&&&&&&& ROUND_ROBIN,
&&&&&&& FAIL_OVER
&&& ///&summary&
&&& /// isolation level
&&& ///&/summary&
&&& public
enum IsolationLevel
&&&&&&& LOW,
&&&&&&& HIGH
&&& ///&summary&
&&& /// administrative API Rest
&&& ///&/summary&
&&& public
class AGSAdmin
&&&&&&& private
string username;
&&&&&&& private
string password;
&&&&&&& private
string urlRestAdmin;
&&&&&&& private
string urlRestServer;
&&&&&&& ///&summary&
&&&&&&& /// Initializes a new instance of the
&see cref=&AGSAdmin&/& class.
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&serverName&&server name&/param&
&&&&&&& ///&param name=&port&&port of server&/param&
&&&&&&& ///&param name=&username&&username administrator&/param&
&&&&&&& ///&param name=&password&&password administrator&/param&
&&&&&&& public
AGSAdmin(string
serverName, int
port, string username,
string password)
&&&&&&&&&&& this.username =
&&&&&&&&&&& this.password =
&&&&&&&&&&& string
url = string.Format(&http://{0}:{1}/arcgis&,
serverName, port.ToString());
&&&&&&&&&&& this.urlRestAdmin =
url + &/admin&;
&&&&&&&&&&& this.urlRestServer =
url + &/server&;
&&&&&&& ///&summary&
&&&&&&& /// Prevents a default instance of the
&see cref=&AGSAdmin&/& class from being created.
&&&&&&& ///&/summary&
&&&&&&& private
AGSAdmin()
&&&&&&& ///&summary&
&&&&&&& /// Create arcgis server folder
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&folderName&&Folder name&/param&
&&&&&&& ///&param name=&description&&Description of the folder&/param&
&&&&&&& ///&returns&True if successfully created&/returns&
&&&&&&& public
bool CreateServerFolder(string
folderName, string
description)
&&&&&&&&&&& try
&&&&&&&&&&& {
&&&&&&&&&&&&&&& string
token = this.GenerateAGSToken();
&&&&&&&&&&&&&&& string
folderUrl = this.urlRestAdmin +
&/services/& + folderName +
&?f=json&token=& +
&&&&&&&&&&&&&&& string
resultExistsFolder = this.GetResult(folderUrl);
&&&&&&&&&&&&&&& if (!this.HasError(resultExistsFolder))
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& return
true; // exists
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& else
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& string
createFolderUrl = this.urlRestAdmin +
&/services/createFolder&;
&&&&&&&&&&&&&&&&&&& string
postContent = string.Format(&folderName={0}&description={1}&f=json&token={2}&,
folderName, description,
&&&&&&&&&&&&&&&&&&& string
result = this.GetResult(createFolderUrl,
postContent);
&&&&&&&&&&&&&&&&&&& return
this.HasSuccess(result);
&&&&&&&&&&&&&&& }
&&&&&&&&&&& }
&&&&&&&&&&& catch
&&&&&&&&&&& {
&&&&&&&&&&&&&&& return
&&&&&&&&&&& }
&&&&&&& ///&summary&
&&&&&&& /// Get physical Path and virtual Path from directory ags
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&directory&&directory ags&/param&
&&&&&&& ///&param name=&physicalPath&&physical Path&/param&
&&&&&&& ///&param name=&virtualPath&&virtual Path&/param&
&&&&&&& ///&returns&True if successfully return path&/returns&
&&&&&&& public
bool GetServerDirectory(string
directory, out
string physicalPath,
out string
virtualPath)
&&&&&&&&&&& physicalPath =
&&&&&&&&&&& virtualPath =
&&&&&&&&&&& try
&&&&&&&&&&& {
&&&&&&&&&&&&&&& string
token = this.GenerateAGSToken();
&&&&&&&&&&&&&&& string
directoryUrl = this.urlRestAdmin +
&/system/directories/& +
directory + &?f=json&token=& +
&&&&&&&&&&&&&&& string
result = this.GetResult(directoryUrl);
&&&&&&&&&&&&&&& JsonObject
jsonObject = new
JsonObject(result);
&&&&&&&&&&&&&&& if (!jsonObject.Exists(&physicalPath&) || !jsonObject.TryGetString(&physicalPath&,
out physicalPath))
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& throw
new Exception();
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& jsonObject =
new JsonObject(result);
&&&&&&&&&&&&&&& if (!jsonObject.Exists(&virtualPath&) || !jsonObject.TryGetString(&virtualPath&,
out virtualPath))
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& throw
new Exception();
&&& &&&&&&&&&&&&}
&&&&&&&&&&&&&&& return
&&&&&&&&&&& }
&&&&&&&&&&& catch
&&&&&&&&&&& {
&&&&&&&&&&&&&&& return
&&&&&&&&&&& }
&&&&&&& ///&summary&
&&&&&&& /// Delete Service
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&serviceName&&Service Name&/param&
&&&&&&& ///&param name=&serviceType&&Server Type&/param&
&&&&&&& ///&returns&True if successfully deleted&/returns&
&&&&&&& public
bool DeleteService(string
serviceName, ServiceType
serviceType)
&&&&&&&&&&& try
&&&&&&&&&&& {
&&&&&&&&&&&&&&& string
token = this.GenerateAGSToken();
&&&&&&&&&&&&&&& string
serviceUrl = this.urlRestAdmin +
&/services/& + serviceName +
&.& + Enum.GetName(typeof(ServiceType),
serviceType) + &/delete&;
&&&&&&&&&&&&&&& string
result = this.GetResult(serviceUrl,
&f=json&token=& +
&&&&&&&&&&&&&&& return
this.HasSuccess(result);
&&&&&&&&&&& }
&&&&&&&&&&& catch
&&&&&&&&&&& {
&&&&&&&&&&&&&&& return
&&&&&&&&&&& }
&&&&&&& ///&summary&
&&&&&&& /// Start Service
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&serviceName&&Service Name&/param&
&&&&&&& ///&param name=&serviceType&&Server Type&/param&
&&&&&&& ///&returns&True if successfully started&/returns&
&&&&&&& public
bool StartService(string
serviceName, ServiceType
serviceType)
&&&&&&&&&&& try
&&&&&&&&&&& {
&&&&&&&&&&&&&&& string
token = this.GenerateAGSToken();
&&&&&&&&&&&&&&& string
serviceUrl = this.urlRestAdmin +
&/services/& + serviceName +
&.& + Enum.GetName(typeof(ServiceType),
serviceType) + &/start&;
&&&&&&&&&&&&&&& string
result = this.GetResult(serviceUrl,
&f=json&token=& +
&&&&&&&&&&&&&&& return
this.HasSuccess(result);
&&&&&&&&&&& }
&&&&&&&&&&& catch
&&&&&&&&&&& {
&&&&&&&&&&&&&&& return
&&&&&&&&&&& }
&&&&&&& ///&summary&
&&&&&&& /// Stop Service
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&serviceName&&Service Name&/param&
&&&&&&& ///&param name=&serviceType&&Server Type&/param&
&&&&&&& ///&returns&True if successfully stopped&/returns&
&&&&&&& public
bool StopService(string
serviceName, ServiceType
serviceType)
&&&&&&&&&&& try
&&&&&&&&&&& {
&&&&&&&&&&&&&&& string
token = this.GenerateAGSToken();
&&&&&&&&&&&&&&& string
serviceUrl = this.urlRestAdmin +
&/services/& + serviceName +
&.& + Enum.GetName(typeof(ServiceType),
serviceType) + &/stop&;
&&&&&&&&&&&&&&& string
result = this.GetResult(serviceUrl,
&f=json&token=& +
&&&&&&&&&&&&&&& return
this.HasSuccess(result);
&&&&&&&&&&& }
&&&&&&&&&&& catch
&&&&&&&&&&& {
&&&&&&&&&&&&&&& return
&&&&&&&&&&& }
&&&&&&& ///&summary&
&&&&&&& /// list of services
&&&&&&& ///&/summary&
&&&&&&& public
void ListServices()
&&&&&&&&&&& this.ListServices(null);
&&&&&&& ///&summary&
&&&&&&& /// list of services in folder
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&folder&&name of folder&/param&
&&&&&&& public
void ListServices(string
&&&&&&&&&&& try
&&&&&&&&&&& {
&&&&&&&&&&&&&&& string
token = this.GenerateAGSToken();
&&&& &&&&&&&&&&&string
serviceUrl = this.urlRestAdmin +
&/services/& + folder;
&&&&&&&&&&&&&&& string
postcontent = &f=json&token=& +
&&&&&&&&&&&&&&& string
result = this.GetResult(serviceUrl,
postcontent);
&&&&&&&&&&&&&&& JsonObject
jsonObject = new
JsonObject(result);
&&&&&&&&&&&&&&& object[]
folders = null;
&&&&&&&&&&&&&&& if (jsonObject.Exists(&folders&) &&
jsonObject.TryGetArray(&folders&,
out folders))
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& foreach (string
subfolder in
&&&&&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&&&&&& this.ListServices(subfolder);
&&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& object[]
services = null;
&&&&&&&&&&&&&&& if (jsonObject.Exists(&services&) &&
jsonObject.TryGetArray(&services&,
out services))
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& IEnumerable&JsonObject&
jsonObjectService =
services.Cast&JsonObject&();
&&&&&&&&&&&&&&&&&&& jsonObjectService.ToList().ForEach(jo =&
&&&&&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&&&&&& string
serviceName;
&&&&&&&&&&& &&&&&&&&&&&&jo.TryGetString(&serviceName&,
out serviceName);
&&&&&&&&&&&&&&&&&&&&&&& string
folderName;
&&&&&&&&&&&&&&&&&&&&&&& jo.TryGetString(&folderName&,
out folderName);
&&&&&&&&&&&&&&&&&&&&&&& Console.WriteLine(folderName +
&/& + serviceName);
&&&&&&&&&&&&&&&&&&& });
&&&&&&&&&&&&&&& }
&&&&&&&&&&& }
&&&&&&&&&&& catch
&&&&&&&&&&& {
&&&&&&&&&&&&&&& throw;
&&&&&&&&&&& }
&&&&&&& ///&summary&
&&&&&&& /// create service type MapServer
&&&&&&& ///&/summary&
&&&&&&& ///&returns&&True if successfully created&/returns&
&&&&&&& public
bool CreateService(String )
&&&&&&&&&&& try
&&&&&&&&&&& {
&&&&&&&&&&&&&&& string
token = this.GenerateAGSToken();
&&&&&&&&&&&&&&& string
serviceUrl = this.urlRestAdmin +
&/services/createService&;
&&&&&&&&&&&&&&& JsonObject
jsonObject = new
JsonObject();
&&&&&&&&&&&&&&& jsonObject.AddString(&serviceName&,
&&&&&&&&&&&&&&& jsonObject.AddString(&type&,
Enum.GetName(typeof(ServiceType),
ServiceType.MapServer));
&&&&&&&&&&&&&&& jsonObject.AddString(&description&,
&This is an example&);
&&&&&&&&&&&&&&& jsonObject.AddString(&capabilities&,
&Map,Query,Data&);
&&&&&&&&&&&&&&& 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 /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
&&&&&&&&&&&&&&& // Other service types do not require you to use arcpy.mapping or create an MSD.
&&&&&&&&&&&&&&& jsonObjectProperties.AddString(&filePath&, msdPath);
// required
&&&&&&&&&&&&&&& 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&);
// 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=& +
&&&&&&&&&&&&&&& return
this.HasSuccess(result);
&&&&&&&&&&& }
&&&&&&&&&&& catch
&&&&&&&&&&& {
&&&&&&&&&&&&&&& return
&&&&&&&&&&& }
&&&&&&& ///&summary&
&&&&&&& /// check is status is equal success
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&result&&result of request&/param&
&&&&&&& ///&returns&True if status is equal success&/returns&
&&&&&&& private
bool HasSuccess(string
&&&&&&&&&&& JsonObject
jsonObject = new
JsonObject(result);
&&&&&&&&&&& string
status = null;
&&&&&&&&&&& if (!jsonObject.Exists(&status&) || !jsonObject.TryGetString(&status&,
out status))
&&&&&&&&&&& {
&&&&&&&&&&&&&&& return
&&&&&&&&&&& }
&&&&&&&&&&& return
status == &success&;
&&&&&&& ///&summary&
&&&&&&& /// check is status is equal error
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&result&&result of request&/param&
&&&&&&& ///&returns&True if status is equal error&/returns&
&&&&&&& private
bool HasError(string
&&&&&&&&&&& JsonObject
jsonObject = new
JsonObject(result);
&&&&&&&&&&& string
status = null;
&&&&&&&&&&& if (!jsonObject.Exists(&status&) || !jsonObject.TryGetString(&status&,
out status))
&&&&&&&&&&& {
&&&&&&&&&&&&&&& return
&&&&&&&&&&& }
&&&&&&&&&&& return
status == &error&;
&&&&&&& ///&summary&
&&&&&&& /// Get request rest
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&url&&url of request&/param&
&&&&&&& ///&returns&return response&/returns&
&&&&&&& private
string GetResult(string
&&&&&&&&&&& try
&&&&&&&&&&& {
&&&&&&&&&&&&&&& WebRequest
request = WebRequest.Create(url);
&&&&&&&&&&&&&&& WebResponse
response = request.GetResponse();
&&&&&&&&&&&&&&& using (Stream
responseStream = response.GetResponseStream())
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& using (StreamReader
reader = new
StreamReader(responseStream))
&&&&&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&&&&&& return
reader.ReadToEnd();
&&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& }
&&&&&&&&&&& }
&&&&&&&&&&& catch
&&&&&&&&&&& {
&&&&&&&&&&&&&&& throw;
&&&&&&&&&&& }
&&&&&&& ///&summary&
&&&&&&& /// Post request rest
&&&&&&& ///&/summary&
&&&&&&& ///&param name=&url&&url of request&/param&
&&&&&&& ///&param name=&postContent&&content of post&/param&
&&&&&&& ///&returns&return response&/returns&
&&&&&&& private
string GetResult(string
url, string
postContent)
&&&&&&&&&&& try
&&&&&&&&&&& {
&&&&&&&&&&&&&&& WebRequest
request = WebRequest.Create(url);
&&&&&&&&&&&&&&& byte[]
content = Encoding.UTF8.GetBytes(postContent);
&&&&&&&&&&&&&&& request.ContentLength =
content.Length;
&&&&&&&&&&&&&&& request.ContentType =
&application/x-www-form-urlencoded&;
&&&&&&&&&&&&&&& request.Method =
WebRequestMethods.Http.Post;
&&&&&&&&&&&&&&& using (Stream
requestStream = request.GetRequestStream())
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& requestStream.Write(content, 0,
content.Length);
&&&&&&&&&&&&&&&&&&& requestStream.Close();
&&&&&&&&&&&&&&&&&&& WebResponse
response = request.GetResponse();
&&&&&&&&&&&&&&&&&&& using (Stream
responseStream = response.GetResponseStream())
&&&&&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&&&&&& using (StreamReader
reader = new
StreamReader(responseStream))
&&&&&&&&&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&&&&&&&&&& return
reader.ReadToEnd();
&&&&&&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&&&& &}
&&&&&&&&&&&&&&& }
&&&&&&&&&&& }
&&&&&&&&&&& catch
&&&&&&&&&&& {
&&&&&&&&&&&&&&& throw;
&&&&&&&&&&& }
&&&&&&& ///&summary&
&&&&&&& /// Generate a token
&&&&&&& ///&/summary&
&&&&&&& ///&returns&A token that has default expiration time&/returns&
&&&&&&& private
string GenerateAGSToken()
&&&&&&&&&&& try
&&&&&&&&&&& {
&&&&&&&&&&&&&&& string
urlGenerateToken = string.Format(&{0}/generateToken&,
this.urlRestAdmin);
&&&&&&&&&&&&&&& string
credential = string.Format(&username={0}&password={1}&client=requestip&expiration=&f=json&,
this.username,
this.password);
&&&&&&&&&&&&&&& string
result = this.GetResult(urlGenerateToken,
credential);
&&&&&&&&&&&&&&& JsonObject
jsonObject = new
JsonObject(result);
&&&&&&&&&&&&&&& string
token = null;
&&&&&&&&&&&&&&& if (!jsonObject.Exists(&token&) || !jsonObject.TryGetString(&token&,
out token))
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& throw
new Exception(&Token not found!&);
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& return
&&&&&&&&&&& }
&&&&&&&&&& &catch
&&&&&&&&&&& {
&&&&&&&&&&&&&&& return
string.Empty;
&&&&&&&&&&& }
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:568554次
积分:10426
积分:10426
排名:第436名
原创:399篇
转载:41篇
译文:86篇
评论:333条
(1)(2)(5)(2)(12)(1)(3)(26)(3)(2)(6)(18)(4)(9)(21)(31)(6)(15)(34)(32)(9)(5)(108)(171)

我要回帖

更多关于 arcgis10.2安装教程 的文章

 

随机推荐