ArcGIS Server代碼動態創建發布服務(MapServer,ImageServer)


ArcGIS Server動態創建MapServer

#region 創建地圖服務  
02.  private bool CreateServices(string MapPath, string ServerName)//ServerName為地圖服務設置的服務名  
03.  {  
04.      ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(MapServerUserName, MapserverPass, "");//MapServerUserName和MapserverPass為連接ArcGIS Server的用戶名和密碼  
05.      ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsConnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(HostName, identity);//HostName為ArcGIS Server所在服務器的主機名  
06.      agsConnection.Connect();  
07.      IServerObjectAdmin pServerObjectAdmin;  
08.      pServerObjectAdmin = agsConnection.ServerObjectAdmin;  
09.      IServerObjectConfiguration2 configuration = (IServerObjectConfiguration2)pServerObjectAdmin.CreateConfiguration();  
10.      configuration.Name = ServerName;//發布Service的名稱,必填  
11.      configuration.TypeName = "MapServer";//發布服務的類型,如:MapServer,GeocodeServer  
12.      IPropertySet props = configuration.Properties;  
13.      props.SetProperty("FilePath", MapPath);//設置MXD的路徑  
14.      props.SetProperty("OutputDir", "c:\\arcgisserver\\arcgisoutput");//圖片的輸出目錄  
15.      props.SetProperty("VirtualOutPutDir", "http://" + HostName + "/arcgisoutput");//圖片輸出的虛擬路徑  
16.      props.SetProperty("SupportedImageReturnTypes", "URL");//支持的圖片類型  
17.      props.SetProperty("MaxImageHeight", "2048");//圖片的最大高度  
18.      props.SetProperty("MaxRecordCount", "500");//返回記錄的最大條數  
19.      props.SetProperty("MaxBufferCount", "100");//緩沖區分析的最大數目  
20.      props.SetProperty("MaxImageWidth", "2048");//圖片的最大寬度  
21.      props.SetProperty("IsCached", "false");//是否切片  
22.      props.SetProperty("CacheOnDemand", "false");//是否主動切片  
23.      props.SetProperty("IgnoreCache", "false");//是否忽略切片  
24.      props.SetProperty("ClientCachingAllowed", "true");//是否允許客戶端緩沖  
25.      props.SetProperty("CacheDir", "c:\\arcgisserver\\arcgiscache\\NewService");//切片的輸出路徑  
26.      props.SetProperty("SOMCacheDir", "c:\\arcgisserver\\arcgiscache");//som的切片輸出路徑  
27.  
28.      //configuration.Description = "NewService";//Service的描述  
29.      configuration.IsolationLevel = esriServerIsolationLevel.esriServerIsolationHigh;//或者esriServerIsolationLow,esriServerIsolationAny  
30.      configuration.IsPooled = true;//是否池化  
31.      configuration.MaxInstances = 2;//最多的實例數  
32.      configuration.MinInstances = 1;//最少的實例數  
33.  
34.      ////設置刷新  
35.      IPropertySet recycleProp = configuration.RecycleProperties;  
36.      recycleProp.SetProperty("StartTime", "00:00");//刷新開始時間  
37.      recycleProp.SetProperty("Interval", "3600");//刷新間隔  
38.  
39.      ////設置是否開啟REST服務  
40.      IPropertySet infoProp = configuration.Info;  
41.      infoProp.SetProperty("WebEnabled", "true");//是否提供REST服務  
42.      infoProp.SetProperty("WebCapabilities", "Map,Query,Data");//提供何種服務  
43.  
44.      //configuration.StartupType = esriStartupType.esriSTAutomatic;//或者esriSTManual  
45.      //configuration.UsageTimeout = 120;//客戶端占用一個服務的最長時間  
46.      //configuration.WaitTimeout = 120;//客戶端申請一個服務的最長等待時間  
47.      #endregion  
48.  
49.      //添加服務到Server  
50.      pServerObjectAdmin.AddConfiguration(configuration);  
51.  
52.      //啟動服務  
53.      pServerObjectAdmin.StartConfiguration(ServerName, "MapServer");//設置服務類型為MapServer,並啟動服務  
54.      return true;  
55.  
56.  }  
57.  #endregion 

 ArcGIS Server動態創建ImageServer 

[csharp] view plaincopyprint?
01.   private bool CreateServices(string ImagePath, string ServerName)  
02.    {  
03.         ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(MapServerUserName, MapserverPass, "");  
04.        ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsConnection = new   
05.  
06.  
07.ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(HostName, identity);  
08.        agsConnection.Connect();  
09.        IServerObjectAdmin pServerObjectAdmin;  
10.        pServerObjectAdmin = agsConnection.ServerObjectAdmin;  
11.        IServerObjectConfiguration2 configuration = (IServerObjectConfiguration2)pServerObjectAdmin.CreateConfiguration();  
12.        configuration.Name = ServerName;//發布Service的名稱,必填  
13.        configuration.TypeName = "ImageServer";//發布服務的類型,如:MapServer,GeocodeServer  
14.        IPropertySet propertySet = configuration.Properties;  
15.<span style="color: rgb(255, 0, 0);">        propertySet.SetProperty("Path", ImagePath);//設置Image的路徑</span>  
16.        propertySet.SetProperty("Start", "00:00");  
17.        propertySet.SetProperty("Interval", "24");  
18.        propertySet.SetProperty("SupportedImageReturnTypes", "URL");  
19.<span style="color: rgb(255, 153, 0);"> propertySet.SetProperty("OutputDir", "c:\\arcgisserver\\arcgisoutput");//圖片的輸出目錄  
20.    propertySet.SetProperty("VirtualOutPutDir", "http://" + HostName + "/arcgisoutput");//圖片輸出的虛擬路徑</span>  
21.        //propertySet.SetProperty("MaxImageHeight", 4100);//4100  
22.       // propertySet.SetProperty("MaxImageWidth", 15000);//15000  
23.        //propertySet.SetProperty("AllowedCompressions", "None,JPEG,LZ77");//"None,JPEG,LZ77"  
24.        //propertySet.SetProperty("DefaultResamplingMethod", 0);//0  
25.        //propertySet.SetProperty("DefaultCompressionQuality", 75);//75  
26.        //propertySet.SetProperty("MaxRecordCount", 500);//500  
27.        //propertySet.SetProperty("MaxMosaicImageCount", 1);//20  
28.        //propertySet.SetProperty("MaxDownloadImageCount", 20);//20  
29.        //propertySet.SetProperty("AllowedFields","Name,MinPS,MaxPS,LowPS,HighPS,CenterX,CenterY");//"Name,MinPS,MaxPS,LowPS,HighPS,CenterX,CenterY"  
30.        //propertySet.SetProperty("AllowedMosaicMethods","Center,NorthWest,LockRaster,ByAttribute,Nadir,Viewpoint,Seamline");//"Center,NorthWest,LockRaster,ByAttribute,Nadir,Viewpoint,Seamline"  
31.        //propertySet.SetProperty("AllowedItemMetadata", "Full");//"Full"  
32.        //ImageServiceInfo pImageSerivce = new ImageServiceInfo();  
33.        configuration.StartupType = esriStartupType.esriSTAutomatic;  
34.        configuration.MinInstances = 1;  
35.        configuration.MaxInstances = 2;  
36.    configuration.IsPooled = true;  
37.        configuration.Info.SetProperty("WebEnabled", "true");  
38.        configuration.Info.SetProperty("WebCapabilities", "Image,Catalog,Metadata,Download,Pixels");  
39.        pServerObjectAdmin.AddConfiguration(configuration);  
40.        //啟動服務  
41.        pServerObjectAdmin.StartConfiguration(ServerName, "ImageServer");//設置服務類型並啟動服務  
42.        return true;  
43.    }  

 http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/AddConfiguration_Method/003z0000009z000000/

轉自:http://blog.csdn.net/lxping1012/article/details/7565342


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM