zoukankan      html  css  js  c++  java
  • Arcengine动态发布WMS

                if (this.textBox1.Text == "")
                {
                    MessageBox.Show("请输入主机名!");
                    return;
                }
                if (this.textBox2.Text == "")
                {
                    MessageBox.Show("请输入发布服务名称!");
                    return;
                }
                if (this.textBox3.Text == "")
                {
                    MessageBox.Show("请选择发布MXD文件路径!");
                    return;
                }

                //获取发布的主机名称,服务名称,发布文件的地址
               string hostname = this.textBox1.Text;
               string servername = this.textBox2.Text;
               string filepath = this.textBox3.Text;
             
                IGISServerConnection pGISServerConnection = new GISServerConnectionClass();
               //请注意:connect输入的主机名,表示要连接的服务器
               pGISServerConnection.Connect(hostname);
             
               IServerObjectAdmin pServerObjectAdmin;
               pServerObjectAdmin = pGISServerConnection.ServerObjectAdmin;
               IServerObjectConfiguration2 configuration = (IServerObjectConfiguration2)pServerObjectAdmin.CreateConfiguration();

               //获得server服务器列表,判断发布的服务是否存在
               IEnumServerObjectConfiguration ss = pServerObjectAdmin.GetConfigurations();
               IServerObjectConfiguration2 pp;
               for (int i = 0; i < ss.Count; i++)
               {
                   pp = (IServerObjectConfiguration2)ss.Next();
                   String name = pp.Name;
                   if (name == servername)
                   {
                       MessageBox.Show("发布的服务名称已经存在!");
                       return;
                   }
               }

               configuration.Name = servername;//发布Service的名称,必填
               configuration.TypeName = "MapServer";//发布服务的类型,如:MapServer,GeocodeServer
               IPropertySet props = configuration.Properties;
               //props.SetProperty("FilePath", @"E:\Program Files\ArcGIS\DeveloperKit\SamplesNET\data\World\world.mxd");//设置MXD的路径
               props.SetProperty("FilePath", filepath);//设置MXD的路径
                //一下的property并非必须,只要一个filepath就可以发布


               props.SetProperty("OutputDir", "c:\\arcgisserver\\arcgisoutput");//图片的输出目录
               string VirtualOutPutDir = "http://" + hostname + "/arcgisoutput";
               props.SetProperty("VirtualOutPutDir", VirtualOutPutDir);//图片输出的虚拟路径
               props.SetProperty("SupportedImageReturnTypes", "URL");//支持的图片类型
               props.SetProperty("MaxImageHeight", "2048");//图片的最大高度
               props.SetProperty("MaxRecordCount", "500");//返回记录的最大条数
               props.SetProperty("MaxBufferCount", "100");//缓冲区分析的最大数目
               props.SetProperty("MaxImageWidth", "2048");//图片的最大宽度
               props.SetProperty("IsCached", "false");//是否切片
               props.SetProperty("CacheOnDemand", "false");//是否主动切片
               props.SetProperty("IgnoreCache", "false");//是否忽略切片
               props.SetProperty("ClientCachingAllowed", "true");//是否允许客户端缓冲
               string CacheDir = "c:\\arcgisserver\\arcgiscache\\" + servername;
               props.SetProperty("CacheDir", CacheDir);//切片的输出路径
               props.SetProperty("SOMCacheDir", "c:\\arcgisserver\\arcgiscache");//som的切片输出路径

                //设置WMS
                configuration.set_ExtensionEnabled("WMSServer", true);
                IPropertySet wmsprops = configuration.get_ExtensionProperties("WMSServer");
                wmsprops.SetProperty("CustomGetCapabilities", "false");
                wmsprops.SetProperty("PathToCustomGetCapabilitiesFiles", "");
                wmsprops.SetProperty("Name", "WMS");
                wmsprops.SetProperty("Title", servername);
                wmsprops.SetProperty("Abstract", "");
                wmsprops.SetProperty("Keyword", "");
                string OnlineResource = hostname + "/arcgis/services/" + servername + "/MapServer/WMSServer";
                wmsprops.SetProperty("OnlineResource", OnlineResource);
                wmsprops.SetProperty("ContactPerson", "");
                wmsprops.SetProperty("ContactPosition", "");
                wmsprops.SetProperty("ContactOrganization", "");
                wmsprops.SetProperty("AddressType", "");
                wmsprops.SetProperty("City", "");
                wmsprops.SetProperty("StateOrProvince", "");
                wmsprops.SetProperty("PostCode", "");
                wmsprops.SetProperty("Country", "");
                wmsprops.SetProperty("ContactVoiceTelephone", "");
                wmsprops.SetProperty("ContactFacsimileTelephone", "");
                wmsprops.SetProperty("ContactElectronicMailAddress", "");
                wmsprops.SetProperty("Fees", "");
                wmsprops.SetProperty("AccessConstraints", "");
                configuration.set_ExtensionProperties("WMSServer", wmsprops);
                IPropertySet wmsinfo = configuration.get_ExtensionInfo("WMSServer");
                wmsinfo.SetProperty("WebEnabled", "true");
                wmsinfo.SetProperty("WebCapabilities", "");
                configuration.set_ExtensionInfo("WMSServer", wmsinfo);


                configuration.Description = servername;//Service的描述
                configuration.IsolationLevel = esriServerIsolationLevel.esriServerIsolationHigh;//或者esriServerIsolationLow,esriServerIsolationAny
                configuration.IsPooled = true;//是否池化
                configuration.MaxInstances = 1;//最多的实例数
                configuration.MinInstances = 1;//最少的实例数
               
                //设置刷新
                IPropertySet recycleProp = configuration.RecycleProperties;
                recycleProp.SetProperty("StartTime", "00:00");//刷新开始时间
                recycleProp.SetProperty("Interval", "3600");//刷新间隔
                //设置是否开启REST服务
                IPropertySet infoProp = configuration.Info;
                infoProp.SetProperty("WebEnabled", "true");//是否提供REST服务
                infoProp.SetProperty("WebCapabilities", "Map,Query,Data");//提供何种服务
                configuration.StartupType = esriStartupType.esriSTAutomatic;//或者esriSTManual
                configuration.UsageTimeout = 120;//客户端占用一个服务的最长时间
                configuration.WaitTimeout = 120;//客户端申请一个服务的最长等待时间


                 configuration.set_ExtensionEnabled("WMSServer", true);
                //添加服务到Server
                pServerObjectAdmin.AddConfiguration(configuration);
                //删除服务
                //pServerObjectAdmin.DeleteConfiguration("NewService", "MapServer");
                //启动服务
                pServerObjectAdmin.StartConfiguration(servername, "MapServer");
                MessageBox.Show("发布成功!");
  • 相关阅读:
    iOS 整理面试题(上)
    2021年十大白马名单
    RabbitMQ:消息重复消费
    RabbitMQ:保证消息的顺序性
    RabbitMQ:保证消息的可靠性传输
    AWS S3 大文件分片上传
    rebase 用法小结
    Flask at scale
    MySQL分区
    动态规划示例题
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/2093214.html
Copyright © 2011-2022 走看看