/// <summary>
/// 连接地图服务
/// </summary>
/// <param name="pHostOrUrl"></param>
/// <param name="pServiceName"></param>
/// <param name="userName"></param>
/// <param name="pwd"></param>
/// <param name="pIsLAN">是否有访问权限默认为没有true</param>
/// <returns></returns>
public IMapServer GetMapServer(string pHostOrUrl, string pServiceName, string userName = "", string pwd = "", bool pIsLAN = true)
{
IPropertySet pPropertySet = new PropertySetClass();
IMapServer pMapServer = null;
try
{
if (string.IsNullOrEmpty(userName)) pIsLAN = true;
if (pIsLAN)
pPropertySet.SetProperty("machine", pHostOrUrl);
else
{
pPropertySet.SetProperty("url", pHostOrUrl);
pPropertySet.SetProperty("user", userName);
pPropertySet.SetProperty("password", pwd);
}
Type factoryType = Type.GetTypeFromProgID("esriGISClient.AGSServerConnectionFactory");
IAGSServerConnectionFactory pFactory = (IAGSServerConnectionFactory)Activator.CreateInstance(factoryType);
IAGSServerConnection pConnection = pFactory.Open(pPropertySet, 0);
IAGSEnumServerObjectName pServerObjectNames = pConnection.ServerObjectNames;
IAGSServerObjectName ServerObjectName = pServerObjectNames.Next();
while (ServerObjectName != null)
{
if ((ServerObjectName.Name.ToLower() == pServiceName.ToLower()) &&
(ServerObjectName.Type == "MapServer"))
{
break;
}
ServerObjectName = pServerObjectNames.Next();
}
if (ServerObjectName == null)
{
return null;
}
IName pName = ServerObjectName as IName;
//访问地图服务
IAGSServerObject pServerObject = pName.Open() as IAGSServerObject;
pMapServer = pServerObject as IMapServer;
}
catch (Exception ex)
{
throw new Exception("打开MapServer异常:" + ex.Message + "!\r\n请确认MapServer服务是否有访问权限,如有请配置相应权限后重试。");
}
return pMapServer;
}
arcgisengine 连接服务
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...