/// <summary> /// 设置PDB、GDB工作区 /// </summary> /// <param name="sFilePath">文件路径</param> /// <param name="wstype">工作区类型</param> /// <returns>输出错误Exception</returns> private IWorkspace SetWorkspace(string sFilePath, enumWSType wstype, out Exception eError) { eError = null; IWorkspace pWorkspace = null; try { IPropertySet pPropSet = new PropertySetClass(); switch (wstype) { case enumWSType.PDB: AccessWorkspaceFactory pAccessFact = new AccessWorkspaceFactoryClass(); pPropSet.SetProperty("DATABASE", sFilePath); pWorkspace = pAccessFact.Open(pPropSet, 0); pAccessFact = null; break; case enumWSType.GDB: FileGDBWorkspaceFactoryClass pFileGDBFact = new FileGDBWorkspaceFactoryClass(); pPropSet.SetProperty("DATABASE", sFilePath); pWorkspace = pFileGDBFact.Open(pPropSet, 0); pFileGDBFact = null; break; } pPropSet = null; return(pWorkspace); } catch (Exception eX) { eError = eX; return(null); } }
public static WMTSLayerClass GetWmtsLayer(string Url, string LayerName, string LayerId) { var propSet = new PropertySetClass(); propSet.SetProperty("URL", Url); var wmtsConnFactory = new WMTSConnectionFactoryClass(); var wmtsConnection = wmtsConnFactory.Open(propSet, 0, null); var wmtsServiceDescription = (IWMTSServiceDescription)wmtsConnection; for (int i = 0; i < wmtsServiceDescription.LayerDescriptionCount; i++) { var layerDescription = wmtsServiceDescription.LayerDescription[i]; if (layerDescription.Identifier == LayerId) { var wmtsLayer = new WMTSLayerClass(); IPropertySet propSet_1 = new PropertySetClass(); propSet_1.SetProperty("URL", Url); propSet_1.SetProperty("LayerName", layerDescription.Identifier); var connectionName = new WMTSConnectionNameClass(); connectionName.ConnectionProperties = propSet_1; wmtsLayer.Connect((IName)connectionName); wmtsLayer.Name = LayerName; return(wmtsLayer); } } return(null); }
public static IWorkspace GetWorkspace(Hashtable pPropList, string progID) { try { IPropertySet2 propertySets = new PropertySetClass(); foreach (string paraName in pPropList.Keys) propertySets.SetProperty(paraName.ToUpper(), pPropList[paraName]); IWorkspaceFactory wsf = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass(); return wsf.Open(propertySets, 0); return (new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass()).Open(propertySets, 0); IWorkspaceName2 workspaceName = new WorkspaceNameClass(); workspaceName.ConnectionProperties = propertySets; // 类型库需要动态设置 workspaceName.WorkspaceFactoryProgID = progID; IName pName = workspaceName as IName; IWorkspace workspace = pName.Open() as IWorkspace; //IWorkspace workspace = pName.Open() as IWorkspace; return workspace; } catch (Exception ex) { MessageBox.Show("SDE连接参数不正确,请和系统管理员联系!"); return null; } }
public static IWorkspace GetWorkspace(Hashtable pPropList, string progID) { try { IPropertySet2 propertySets = new PropertySetClass(); foreach (string paraName in pPropList.Keys) { propertySets.SetProperty(paraName.ToUpper(), pPropList[paraName]); } IWorkspaceFactory wsf = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass(); return(wsf.Open(propertySets, 0)); return((new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass()).Open(propertySets, 0)); IWorkspaceName2 workspaceName = new WorkspaceNameClass(); workspaceName.ConnectionProperties = propertySets; // 类型库需要动态设置 workspaceName.WorkspaceFactoryProgID = progID; IName pName = workspaceName as IName; IWorkspace workspace = pName.Open() as IWorkspace; //IWorkspace workspace = pName.Open() as IWorkspace; return(workspace); } catch (Exception ex) { MessageBox.Show("SDE连接参数不正确,请和系统管理员联系!"); return(null); } }
/// <summary> /// 连接地图服务,获取IAGSServerObjectName对象 /// </summary> /// <param name="hostOrUrl">服务地址,例:http://services.arcgisonline.com/ArcGIS/services</param> /// <param name="serviceName">服务名称,例:ESRI_Imagery_World_2D</param> /// <param name="isLAN">是否局域网(Local Area Network)</param> /// <returns></returns> private IAGSServerObjectName GetServerObjectName(string hostOrUrl, string serviceName, bool isLAN = false) { //设置连接属性 IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty(isLAN ? "machine" : "url", hostOrUrl); //打开连接 IAGSServerConnectionFactory factory = new AGSServerConnectionFactory(); IAGSServerConnection connection = factory.Open(propertySet, 0); IAGSEnumServerObjectName serverObjectNames = connection.ServerObjectNames; serverObjectNames.Reset(); IAGSServerObjectName serverObjectName; while ((serverObjectName = serverObjectNames.Next()) != null) { if (serverObjectName.Name.ToLower() == serviceName.ToLower() && serverObjectName.Type == "MapServer") { break; } } return(serverObjectName); }
protected override void OnClick() { IMxDocument mxDoc = (IMxDocument)ArcMap.Application.Document; IWMSGroupLayer wmsMapLayer = new WMSMapLayerClass(); IWMSConnectionName connName = new WMSConnectionNameClass(); IPropertySet propSet = new PropertySetClass(); propSet.SetProperty("URL", "https://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer"); connName.ConnectionProperties = propSet; //Put the WMS service layers in a DataLayer IDataLayer dataLayer = (IDataLayer)wmsMapLayer; dataLayer.Connect((IName)connName); // Get access to WMS service and layer propeties IWMSServiceDescription serviceDesc = wmsMapLayer.WMSServiceDescription; IWMSLayerDescription groupDesc = serviceDesc.LayerDescription[0]; //Clear existing WMS service group layer. wmsMapLayer.Clear(); //Create an empty layer and populate it with the desired sub layer index. ILayer newLayer; IWMSLayer newWMSLayer = wmsMapLayer.CreateWMSLayer(groupDesc.LayerDescription[1]); newLayer = (ILayer)newWMSLayer; wmsMapLayer.InsertLayer(newLayer, 0); //Add the layer to the map. mxDoc.FocusMap.AddLayer((ILayer)wmsMapLayer); IActiveView activeView = (IActiveView)mxDoc.FocusMap; activeView.Refresh(); ArcMap.Application.CurrentTool = null; }
public static Blobber CreateBlobber() { BlobberRepository repository = new BlobberRepository(); repository.StartEdit(); Blobber b = repository.Create(); b.BlobberId = BLOBBER_ID; IFeatureLayer layer = new FeatureLayerClass(); layer.Name = BLOBBER_VALUE_1; IPropertySet properties = new PropertySetClass(); properties.SetProperty("VALUE1", BLOBBER_VALUE_1); properties.SetProperty("VALUE2", BLOBBER_VALUE_2); properties.SetProperty("VALUE3", BLOBBER_VALUE_3); b.Properties = properties; b.Store(); repository.StopEdit(true); return b; }
/// <summary>Apply the OSM Class Extension to the given table</summary> /// <remarks>Obtains an exclusive schema lock if possible otherwise throws an exception</remarks> public static void ApplyOSMClassExtension(this ITable table) { if ((table == null) || (table.Extension is IOSMClassExtension)) return; IClassSchemaEdit3 schemaEdit = table as IClassSchemaEdit3; if (schemaEdit == null) return; int osmIDIndex = table.Fields.FindField("OSMID"); using (SchemaLockManager lockMgr = new SchemaLockManager(table)) { UID osmClassExtensionUID = new UIDClass() { Value = _OSM_CLASS_EXT_GUID }; IPropertySet extensionPropertSet = null; if (osmIDIndex > -1) { // at release 2.1 we changed the OSMID field type to string, hence only when we find the string we are assuming version 2 if (table.Fields.get_Field(osmIDIndex).Type == esriFieldType.esriFieldTypeString) { extensionPropertSet = new PropertySetClass(); extensionPropertSet.SetProperty("VERSION", _OSM_EXTENSION_VERSION); } } schemaEdit.AlterClassExtensionCLSID(osmClassExtensionUID, extensionPropertSet); schemaEdit.AlterClassExtensionProperties(extensionPropertSet); } }
private static IPropertySet GetPropertySet() { RuntimeManager.Bind(ProductCode.EngineOrDesktop); (new AoInitializeClass()).Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard); IPropertySet propertySet = new PropertySetClass(); try { string ServerName = ConfigurationManager.AppSettings["ServerName"].ToString(); string InstanceName = ConfigurationManager.AppSettings["InstanceName"].ToString(); string DBName = ConfigurationManager.AppSettings["DatabaseName"].ToString(); string UserName = ConfigurationManager.AppSettings["UserName"].ToString(); string UserPassword = ConfigurationManager.AppSettings["UserPassword"].ToString(); propertySet.SetProperty("Server", ServerName); propertySet.SetProperty("Instance", InstanceName); propertySet.SetProperty("Database", DBName); propertySet.SetProperty("user", UserName); propertySet.SetProperty("password", UserPassword); propertySet.SetProperty("version", "MSD.QC"); } catch (Exception exception) { Exception ee = exception; Assets.logger.Debug(string.Concat("Error from GetPropertySet :", ee.Message, " ", ee.StackTrace)); } return(propertySet); }
private IWorkspace open_ArcSDE_Workspace(string server, string instance, string user, string password, string database, string version, out string serr) { try { ///IPropertySet接口提供对用于管理PropertySet的成员的访问。IPropertySet接口包含在PropertySet中设置和检索命名值对集合的方法。 ///PropertySet是一个通用类,用于保存任何东西的一组属性。使用属性集的一个示例是保存打开SDE工作空间所需的属性,如示例代码所示。 ///通常,属性集可以被认为是一组键(字符串)和值(变体/对象)。一个值得注意的例外是在XmlPropertySet对象上使用IPropertySet接口。 XML文档可以包含具有相同名称的多个元素(即“属性/子”)和不同的值。因此,此接口从XmlPropertySet返回的值可能是锯齿状的二维数组(包含其他数组的数组)。有关更多详细信息和代码示例,请参阅Geodatabase库中的XmlPropertySet coclass'文档。 IPropertySet connectionProperties = new PropertySetClass(); connectionProperties.SetProperty("SERVER", server); connectionProperties.SetProperty("INSTANCE", instance); connectionProperties.SetProperty("DATABASE", database); connectionProperties.SetProperty("USER", user); connectionProperties.SetProperty("PASSWORD", password); connectionProperties.SetProperty("VERSION", version); IWorkspaceFactory factory = new SdeWorkspaceFactoryClass(); IWorkspace workspace = factory.Open(connectionProperties, 0); serr = ""; return(workspace); } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.WorkspaceFun", "open_ArcSDE_Workspace", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); serr = exception.Message; return(null); } }
public static Blobber CreateBlobber() { BlobberRepository repository = new BlobberRepository(); repository.StartEdit(); Blobber b = repository.Create(); b.BlobberId = BLOBBER_ID; IFeatureLayer layer = new FeatureLayerClass(); layer.Name = BLOBBER_VALUE_1; IPropertySet properties = new PropertySetClass(); properties.SetProperty("VALUE1", BLOBBER_VALUE_1); properties.SetProperty("VALUE2", BLOBBER_VALUE_2); properties.SetProperty("VALUE3", BLOBBER_VALUE_3); b.Properties = properties; b.Store(); repository.StopEdit(true); return(b); }
public object GetWorkspace(string strType, string strArgs) { IWorkspaceFactory wsf = null; IWorkspace m_SystemWorkspace = null; switch (strType) { case "PGDB": wsf = new AccessWorkspaceFactoryClass(); m_SystemWorkspace = wsf.OpenFromFile(strArgs, 0); break; case "FILEGDB": wsf = new ShapefileWorkspaceFactoryClass(); m_SystemWorkspace = wsf.OpenFromFile(strArgs, 0); break; case "SDE": IPropertySet pSet = new PropertySetClass(); string[] argList = strArgs.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string strArg in argList) { string[] argPair = strArg.Split(new char[] { ':' }); pSet.SetProperty(argPair[0], argPair[1]); } wsf = new SdeWorkspaceFactoryClass(); m_SystemWorkspace = wsf.Open(pSet, 0); break; default: throw new Exception("系统Workspace配置了无法识别的数据库:Workspace类型应该在PGDB、FILEGDB和SDE之内"); } return m_SystemWorkspace; }
/// <summary> /// 设置SDE工作区 /// </summary> /// <param name="sServer">服务器名</param> /// <param name="sService">服务名</param> /// <param name="sDatabase">数据库名(SQLServer)</param> /// <param name="sUser">用户名</param> /// <param name="sPassword">密码</param> /// <param name="strVersion">SDE版本</param> /// <returns>输出错误Exception</returns> private IWorkspace SetWorkspace(string sServer, string sService, string sDatabase, string sUser, string sPassword, string strVersion, out Exception eError) { eError = null; IWorkspace pWks = null; IPropertySet pPropSet = new PropertySetClass(); IWorkspaceFactory pSdeFact = new SdeWorkspaceFactoryClass(); pPropSet.SetProperty("SERVER", sServer); pPropSet.SetProperty("INSTANCE", sService); pPropSet.SetProperty("DATABASE", sDatabase); pPropSet.SetProperty("USER", sUser); pPropSet.SetProperty("PASSWORD", sPassword); pPropSet.SetProperty("VERSION", strVersion); try { pWks = pSdeFact.Open(pPropSet, 0); pPropSet = null; pSdeFact = null; return(pWks); } catch (Exception eX) { eError = eX; return(null); } }
/// <summary> /// 创建sde连接参数 /// </summary> /// <param name="serverIP">服务器IP(直连可以为空)</param> /// <param name="instance">数据库实例(基于服务的连接为5151或者esri_sde,如果是直连则为sde:postgresql:localhost)</param> /// <param name="user">sde用户名</param> /// <param name="password">sde用户密码</param> /// <param name="version">sde版本</param> /// <param name="database">数据库名称,一般为sde</param> /// <param name="isDirectConnection">是否直连</param> /// <returns></returns> public IPropertySet CreatePropertySet(string serverIP, string instance, string user, string password, string version, string database, bool isDirectConnection) { IPropertySet pPropertySet = new PropertySetClass(); pPropertySet.SetProperty("USER", user); pPropertySet.SetProperty("PASSWORD", password); pPropertySet.SetProperty("VERSION", version); if (isDirectConnection) { if (instance.Contains(":")) { pPropertySet.SetProperty("INSTANCE", instance); pPropertySet.SetProperty("DATABASE", database); } else { throw new Exception("直连字符串参数'instance'不对,例如 sde:postgresql:localhost"); } } else { pPropertySet.SetProperty("SERVER", serverIP); pPropertySet.SetProperty("INSTANCE", instance); } return(pPropertySet); }
private IWorkspace GetWorkspace(string sFilePath, int wstype) { IWorkspace pWks = null; try { IPropertySet pPropSet = new PropertySetClass(); switch (wstype) { case 1: AccessWorkspaceFactory pAccessFact = new AccessWorkspaceFactoryClass(); pPropSet.SetProperty("DATABASE", sFilePath); pWks = pAccessFact.Open(pPropSet, 0); pAccessFact = null; break; case 2: FileGDBWorkspaceFactoryClass pFileGDBFact = new FileGDBWorkspaceFactoryClass(); pPropSet.SetProperty("DATABASE", sFilePath); pWks = pFileGDBFact.Open(pPropSet, 0); pFileGDBFact = null; break; case 3: break; } pPropSet = null; return(pWks); } catch { return(null); } }
/// <summary> /// 设置PDB、GDB工作区 /// </summary> /// <param name="sFilePath">文件路径</param> /// <param name="wstype">工作区类型</param> /// <returns>输出错误Exception</returns> public bool SetWorkspace(string sFilePath, string type, out Exception eError) { eError = null; try { IPropertySet pPropSet = new PropertySetClass(); switch (type) { case "PDB": AccessWorkspaceFactory pAccessFact = new AccessWorkspaceFactoryClass(); pPropSet.SetProperty("DATABASE", sFilePath); m_Workspace = pAccessFact.Open(pPropSet, 0); pAccessFact = null; m_connset = "PDB;" + sFilePath; break; case "GDB": FileGDBWorkspaceFactoryClass pFileGDBFact = new FileGDBWorkspaceFactoryClass(); pPropSet.SetProperty("DATABASE", sFilePath); m_Workspace = pFileGDBFact.Open(pPropSet, 0); pFileGDBFact = null; m_connset = "GDB;" + sFilePath; break; } pPropSet = null; return(true); } catch (Exception eX) { return(false); } }
private IElement method_1(object object_1) { if (object_1 is DBNull) { return(null); } IMemoryBlobStream o = object_1 as IMemoryBlobStream; IPropertySet set = new PropertySetClass(); IObjectStream pstm = new ObjectStreamClass { Stream = o }; IPersistStream stream3 = set as IPersistStream; stream3.Load(pstm); IElement property = null; try { property = set.GetProperty("Element") as IElement; } catch (Exception) { } ComReleaser.ReleaseCOMObject(stream3); ComReleaser.ReleaseCOMObject(set); ComReleaser.ReleaseCOMObject(o); set = null; return(property); }
public void Init() { // Open workspace and feature class. IWorkspaceFactory wksf = new PostGisWorkspaceFactory(); //Open from zigFile //ws = wksf.OpenFromFile(@"C:\ziggis\ZigGis\example.zig", 0); //Open from PropertySet IPropertySet ps = new PropertySetClass(); ps.SetProperty("server", "localhost"); ps.SetProperty("database", "TUTORIAL"); ps.SetProperty("user", "psqluser"); ps.SetProperty("password", "psqluser"); ps.SetProperty("port", "5432"); ps.SetProperty("configfile", @"C:\ziggis\ZigGis\logging.config"); ws = wksf.Open(ps, 0); IFeatureWorkspace fwks = ws as IFeatureWorkspace; fc = fwks.OpenFeatureClass("zone"); // Create the new layer (default renderer is ISimpleRenderer) layer = new PostGisFeatureLayer(); layer.FeatureClass = fc; layer.Name = fc.AliasName; }
private IWorkspace OpenSDEWorkspace(string server, string instance, string database, string user, string password, string version) { try { IPropertySet propSet = new PropertySetClass(); if (server.Trim() != string.Empty) { propSet.SetProperty("SERVER", server); } propSet.SetProperty("INSTANCE", instance); propSet.SetProperty("DATABASE", database); propSet.SetProperty("USER", user); propSet.SetProperty("PASSWORD", password); propSet.SetProperty("VERSION", version); IWorkspaceFactory wsf = new SdeWorkspaceFactoryClass(); return(wsf.Open(propSet, 0)); } catch (Exception e) { MessageBox.Show(e.Message); return(null); } }
/// <summary>Removes the OSM Class Extension from the given table</summary> /// <remarks>Obtains an exclusive schema lock if possible otherwise throws an exception</remarks> public static void RemoveOSMClassExtension(this ITable table) { if ((table == null) || !(table.Extension is IOSMClassExtension)) { return; } IClassSchemaEdit3 schemaEdit = table as IClassSchemaEdit3; if (schemaEdit == null) { return; } int osmIDIndex = table.Fields.FindField("OSMID"); using (SchemaLockManager lockMgr = new SchemaLockManager(table)) { IPropertySet extensionPropertSet = null; if (osmIDIndex > -1) { // at release 2.1 we changed the OSMID field type to string, hence only when we find the string we are assuming version 2 if (table.Fields.get_Field(osmIDIndex).Type == esriFieldType.esriFieldTypeString) { extensionPropertSet = new PropertySetClass(); extensionPropertSet.SetProperty("VERSION", _OSM_EXTENSION_VERSION); } } schemaEdit.AlterClassExtensionCLSID(null, extensionPropertSet); schemaEdit.AlterClassExtensionProperties(extensionPropertSet); } schemaEdit = null; }
private PropertySetClass GetPropertySet(LoginForm login) { PropertySetClass props = new PropertySetClass(); switch (login.ConnectionType) { case ConnectionType.PersonalGDB: props.SetProperty("DATABASE", login.PersonalGeoDbPath); props.SetProperty("USERNAME", login.UserName); break; case ConnectionType.SDE: props.SetProperty("USER", login.UserName); props.SetProperty("PASSWORD", login.Password); props.SetProperty("VERSION", "SDE.DEFAULT"); props.SetProperty("SERVER", login.Server); props.SetProperty("INSTANCE", login.Instance); break; default: throw (new Exception("Invalid DB Type")); } return(props); }
/// <summary> /// 设置SDE工作区 /// </summary> /// <param name="sServer">服务器名</param> /// <param name="sService">服务名</param> /// <param name="sDatabase">数据库名(SQLServer)</param> /// <param name="sUser">用户名</param> /// <param name="sPassword">密码</param> /// <param name="strVersion">SDE版本</param> /// <returns>输出错误Exception</returns> public IWorkspace SetWorkspace(string sServer, string sService, string sDatabase, string sUser, string sPassword, string strVersion) { //eError = null; IPropertySet pPropSet = new PropertySetClass(); IWorkspaceFactory pSdeFact = new SdeWorkspaceFactoryClass(); pPropSet.SetProperty("SERVER", sServer); pPropSet.SetProperty("INSTANCE", sService); pPropSet.SetProperty("DATABASE", sDatabase); pPropSet.SetProperty("USER", sUser); pPropSet.SetProperty("PASSWORD", sPassword); pPropSet.SetProperty("VERSION", strVersion); try { return(pSdeFact.Open(pPropSet, 0)); } catch (Exception eX) { //******************************** //guozheng added system exception log //if (SysCommon.Log.Module.SysLog == null) // SysCommon.Log.Module.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog(); //SysCommon.Log.Module.SysLog.Write(eX); //******************************** return(null); } }
private IWorkspace CreateWorkspace() { try { IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass(); IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("SERVER", this.Server); propertySet.SetProperty("INSTANCE", this.Instance); propertySet.SetProperty("DATABASE", this.Database); propertySet.SetProperty("USER", this.User); propertySet.SetProperty("PASSWORD", this.PassWord); propertySet.SetProperty("VERSION", this.Version); propertySet.SetProperty("AUTHENTICATION_MODE", this.Authentication_Mode); IWorkspace workspace = workspaceFactory.Open(propertySet, 0); return(workspace); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); } return(null); }
/// <summary> /// 获取SDE数据库工作空间 /// </summary> /// <param name="server">服务器名称或者IP</param> /// <param name="instance">数据库实例名</param> /// <param name="database">SDE数据库名称</param> /// <param name="user">用户名</param> /// <param name="password">用户密码</param> /// <param name="version">连接版本</param> /// <returns></returns> public static ZWorkspace GetSdeWorkspace(string server, string instance, string database, string user, string password, string version = "sde.DEFAULT") { if (string.IsNullOrWhiteSpace(server) || string.IsNullOrWhiteSpace(user) || string.IsNullOrWhiteSpace(password)) { throw new Exception("缺少必要参数,无法打开SDE工作空间"); } else { //SDE数据库采用直连方式,必须加上“sde:oracle11g:”前缀;并且要连上目标机,必须加上服务器名称或者IP if (string.IsNullOrWhiteSpace(instance)) { instance = string.IsNullOrWhiteSpace(server) ? "sde:oracle11g:orcl" : string.Format("sde:oracle11g:{0}/orcl", server); //sde:oracle11g:orcl为连接oracle client配置的主机数据库 } else if (!instance.StartsWith("sde:oracle11g:", StringComparison.OrdinalIgnoreCase)) { instance = string.IsNullOrWhiteSpace(server) ? "sde:oracle11g:" + instance : string.Format("sde:oracle11g:{0}/{1}", server, instance); } try { //sde数据库连接属性设置 IPropertySet pProperty = new PropertySetClass(); pProperty.SetProperty("Server", server); //服务器名称或者IP pProperty.SetProperty("Instance", instance); pProperty.SetProperty("Database", database); //sde数据库名称 pProperty.SetProperty("User", user); //用户名称 pProperty.SetProperty("Password", password); //用户密码 pProperty.SetProperty("Version", version); //连接版本 return(GetSdeWorkspace(pProperty)); } catch (Exception ex) { throw new Exception(string.Format("打开SDE数据库失败"), ex); } } }
private string method_0(object object_0) { if (object_0 is DBNull) { return(""); } IMemoryBlobStream o = object_0 as IMemoryBlobStream; IPropertySet set = new PropertySetClass(); IObjectStream pstm = new ObjectStreamClass { Stream = o }; IPersistStream stream3 = set as IPersistStream; stream3.Load(pstm); string str2 = ""; try { str2 = set.GetProperty("TK").ToString(); } catch (Exception) { } ComReleaser.ReleaseCOMObject(stream3); ComReleaser.ReleaseCOMObject(set); ComReleaser.ReleaseCOMObject(o); set = null; return(str2); }
//根据连接字符串获取工作空间 //此处连接字符串是固定格式的连接串 Server|Service|Database|User|Password|Version private static IWorkspace GetWorkSpacefromConninfo(string conninfostr, int type) { if (conninfostr == "") { return(null); } if (type < 0) { return(null); } int index1 = conninfostr.IndexOf("|"); int index2 = conninfostr.IndexOf("|", index1 + 1); int index3 = conninfostr.IndexOf("|", index2 + 1); int index4 = conninfostr.IndexOf("|", index3 + 1); int index5 = conninfostr.IndexOf("|", index4 + 1); int index6 = conninfostr.IndexOf("|", index5 + 1); IPropertySet pPropSet = new PropertySetClass(); IWorkspaceFactory pWSFact = null; string sServer = ""; string sService = ""; string sDatabase = ""; string sUser = ""; string sPassword = ""; string strVersion = ""; switch (type) { case 1: //mdb pWSFact = new AccessWorkspaceFactoryClass(); sDatabase = conninfostr.Substring(index2 + 1, index3 - index2 - 1); break; case 2: //gdb pWSFact = new FileGDBWorkspaceFactoryClass(); sDatabase = conninfostr.Substring(index2 + 1, index3 - index2 - 1); break; case 3: //sde pWSFact = new SdeWorkspaceFactoryClass(); sServer = conninfostr.Substring(0, index1); sService = conninfostr.Substring(index1 + 1, index2 - index1 - 1); sDatabase = conninfostr.Substring(index2 + 1, index3 - index2 - 1); sUser = conninfostr.Substring(index3 + 1, index4 - index3 - 1); sPassword = conninfostr.Substring(index4 + 1, index5 - index4 - 1); strVersion = conninfostr.Substring(index5 + 1, index6 - index5 - 1); break; } pPropSet.SetProperty("SERVER", sServer); pPropSet.SetProperty("INSTANCE", sService); pPropSet.SetProperty("DATABASE", sDatabase); pPropSet.SetProperty("USER", sUser); pPropSet.SetProperty("PASSWORD", sPassword); pPropSet.SetProperty("VERSION", strVersion); try { IWorkspace pWorkspace = pWSFact.Open(pPropSet, 0); return(pWorkspace); } catch { return(null); } }
private IPropertySet method_3(bool bool_1, bool bool_2) { IPropertySet set = new PropertySetClass(); string str = this.txtServer.Text.Trim(); set.SetProperty("SERVER", str); str = this.txtInstance.Text.Trim(); set.SetProperty("INSTANCE", str); str = this.txtDatabase.Text.Trim(); if (str.Length >= 0) { set.SetProperty("DATABASE", str); } if (bool_1) { str = this.txtUser.Text.Trim(); set.SetProperty("USER", str); str = this.txtPassword.Text.Trim(); set.SetProperty("PASSWORD", str); } if (bool_2) { set.SetProperty("VERSION", this.string_1); } return(set); }
public static IWorkspace connectToSDE() { IPropertySet pPropSet = new PropertySetClass(); pPropSet.SetProperty("Server", "techserver"); pPropSet.SetProperty("Instance", "esri_sde"); pPropSet.SetProperty("user", "sdedata"); pPropSet.SetProperty("password", "sdedata"); pPropSet.SetProperty("version", "sde.DEFAULT"); IWorkspaceFactory pFact; IWorkspace pWorkspace; //IFeatureWorkspace pFeatureWorkspace; try { pFact = new SdeWorkspaceFactoryClass(); pWorkspace = pFact.Open(pPropSet, 0); //pFeatureWorkspace=pWorkspace as IFeatureWorkspace; //pFeatureWorkspace.CreateTable("CJTEST",pFieldsEdit as IFields,null,null,""); return pWorkspace; } catch (Exception ex) { Console.WriteLine(ex.Message); return null; } }
private void btnTestConnection_Click(object sender, EventArgs e) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; IPropertySet connectionProperties = new PropertySetClass(); string str = this.txtServer.Text.Trim(); connectionProperties.SetProperty("SERVER", str); str = this.txtInstance.Text.Trim(); connectionProperties.SetProperty("INSTANCE", str); str = this.txtDatabase.Text.Trim(); if (str.Length >= 0) { connectionProperties.SetProperty("DATABASE", str); } str = this.txtUser.Text.Trim(); connectionProperties.SetProperty("USER", str); str = this.txtPassword.Text.Trim(); connectionProperties.SetProperty("PASSWORD", str); connectionProperties.SetProperty("VERSION", this.string_1); IWorkspaceFactory factory = new SdeWorkspaceFactoryClass(); try { factory.Open(connectionProperties, 0); this.bool_0 = true; this.btnTestConnection.Enabled = false; } catch (Exception exception) { MessageBox.Show(exception.Message); } System.Windows.Forms.Cursor.Current = Cursors.Default; }
/// <summary> /// Creates a property sets the LayerExtension property to "Umbriel" /// </summary> /// <returns>IPropertySet for Umbriel Layer Extention</returns> internal static IPropertySet CreateUmbrielPropertySet() { IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("LayerExtension", "Umbriel"); return(propertySet); }
public object GetWorkspace(string strType, string strArgs) { IWorkspaceFactory wsf = null; IWorkspace m_SystemWorkspace = null; switch (strType) { case "PGDB": wsf = new AccessWorkspaceFactoryClass(); m_SystemWorkspace = wsf.OpenFromFile(strArgs, 0); break; case "FILEGDB": wsf = new ShapefileWorkspaceFactoryClass(); m_SystemWorkspace = wsf.OpenFromFile(strArgs, 0); break; case "SDE": IPropertySet pSet = new PropertySetClass(); string[] argList = strArgs.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string strArg in argList) { string[] argPair = strArg.Split(new char[] { ':' }); pSet.SetProperty(argPair[0], argPair[1]); } wsf = new SdeWorkspaceFactoryClass(); m_SystemWorkspace = wsf.Open(pSet, 0); break; default: throw new Exception("系统Workspace配置了无法识别的数据库:Workspace类型应该在PGDB、FILEGDB和SDE之内"); } return(m_SystemWorkspace); }
private static IWorkspace ConnectToTransactionalVersion(String server, String instance, String user, String password, String database, String version, string authenticationMode) { IWorkspace workspace = null; try { IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("SERVER", server); propertySet.SetProperty("INSTANCE", instance); propertySet.SetProperty("DATABASE", database); propertySet.SetProperty("USER", user); propertySet.SetProperty("PASSWORD", password); propertySet.SetProperty("AUTHENTICATION_MODE", authenticationMode); propertySet.SetProperty("VERSION", version); Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance (factoryType); workspace = workspaceFactory.Open(propertySet, 0); } catch { _message = "عدم توانایی در برقراری ارتباط با پایگاه داده مکانی"; workspace = null; } return(workspace); }
public static ILocatorWorkspace GetSDELocatorWorkspace(String server, String instance, String database, String authenication, String version) { // Set up the SDE connection properties IPropertySet connectionProperties = new PropertySetClass(); connectionProperties.SetProperty("SERVER", server); //propertySet.SetProperty("DBCLIENT", dbclient); connectionProperties.SetProperty("INSTANCE", instance); connectionProperties.SetProperty("DATABASE", database); connectionProperties.SetProperty("AUTHENTICATION_MODE", authenication); connectionProperties.SetProperty("VERSION", version); //connectionProperties.SetProperty("USER", username); //connectionProperties.SetProperty("PASSWORD", pass); // Get the Workspace System.Object obj = Activator.CreateInstance(Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory")); IWorkspaceFactory2 workspaceFactory = obj as IWorkspaceFactory2; IWorkspace workspace = workspaceFactory.Open(connectionProperties, 0); obj = Activator.CreateInstance(Type.GetTypeFromProgID("esriLocation.LocatorManager")); ILocatorManager2 locatorManager = obj as ILocatorManager2; ILocatorWorkspace locatorWorkspace = locatorManager.GetLocatorWorkspace(workspace); IDatabaseLocatorWorkspace databaseLocatorWorkspace = (IDatabaseLocatorWorkspace)locatorWorkspace; return(locatorWorkspace); }
/// <summary> /// 设置SDE工作区 /// </summary> /// <param name="sServer">服务器名</param> /// <param name="sService">服务名</param> /// <param name="sDatabase">数据库名(SQLServer)</param> /// <param name="sUser">用户名</param> /// <param name="sPassword">密码</param> /// <param name="strVersion">SDE版本</param> /// <returns>输出错误Exception</returns> public bool SetWorkspace(string sServer, string sService, string sDatabase, string sUser, string sPassword, string strVersion, out Exception eError) { eError = null; IPropertySet pPropSet = new PropertySetClass(); IWorkspaceFactory pSdeFact = new SdeWorkspaceFactoryClass(); pPropSet.SetProperty("SERVER", sServer); pPropSet.SetProperty("INSTANCE", sService); pPropSet.SetProperty("DATABASE", sDatabase); pPropSet.SetProperty("USER", sUser); pPropSet.SetProperty("PASSWORD", sPassword); pPropSet.SetProperty("VERSION", strVersion); try { m_Workspace = pSdeFact.Open(pPropSet, 0); pPropSet = null; pSdeFact = null; m_connset = "SDE;" + sServer + "|" + sService + "|" + sDatabase + "|" + sUser + "|" + sPassword + "|" + strVersion; return(true); } catch (Exception eX) { return(false); } }
/// <summary> /// 得到连接属性 /// </summary> /// <param name="bSaveUserAndPass"></param> /// <param name="bSaveVersion"></param> /// <returns></returns> private IPropertySet GetConnectionProperty()//bool bSaveUserAndPass, bool bSaveVersion) { string str; IPropertySet pPropertySet = new PropertySetClass(); str = this.teServer.Text.Trim(); pPropertySet.SetProperty("SERVER", str); str = this.teInstance.Text.Trim(); pPropertySet.SetProperty("INSTANCE", str); str = this.teDatabase.Text.Trim(); if (str.Length >= 0) { pPropertySet.SetProperty("DATABASE", str); } str = this.teUserName.Text.Trim(); pPropertySet.SetProperty("USER", str); str = this.teUserPwd.Text.Trim(); pPropertySet.SetProperty("PASSWORD", str); pPropertySet.SetProperty("AUTHENTICATION_MODE", "DBMS"); //if (m_Version == "") //{ // m_Version = "SDE.DEFAULT"; //} //pPropertySet.SetProperty("VERSION", m_Version); return(pPropertySet); }
private IElement method_2(object object_0) { IMemoryBlobStream o = object_0 as IMemoryBlobStream; IPropertySet set = new PropertySetClass(); IObjectStream pstm = new ObjectStreamClass { Stream = o }; ESRI.ArcGIS.esriSystem.IPersistStream stream3 = set as ESRI.ArcGIS.esriSystem.IPersistStream; stream3.Load(pstm); IElement property = null; try { property = set.GetProperty("Element") as IElement; } catch (Exception) { } ComReleaser.ReleaseCOMObject(stream3); ComReleaser.ReleaseCOMObject(set); ComReleaser.ReleaseCOMObject(o); set = null; return(property); }
public static void AddIdahoWms(string idahoId, string groupLayerName, string token) { IGroupLayer groupLayer = new GroupLayerClass(); groupLayer.Name = groupLayerName; var wmsMapLayer = new WMSMapLayerClass(); // create and configure wms connection name, this is used to store the connection properties IWMSConnectionName pConnName = new WMSConnectionNameClass(); IPropertySet propSet = new PropertySetClass(); // create the idaho wms url var idahoUrl = string.Format( "http://idaho.geobigdata.io/v1/wms/idaho-images/{0}/{1}/mapserv?", idahoId, token); // setup the arcmap connection properties propSet.SetProperty("URL", idahoUrl); pConnName.ConnectionProperties = propSet; //uses the name information to connect to the service IDataLayer dataLayer = wmsMapLayer; try { dataLayer.Connect((IName)pConnName); } catch (Exception e) { Jarvis.Logger.Error("Problems connecting to WMS: " + e.Message); } // get wms service description var serviceDesc = wmsMapLayer.IWMSGroupLayer_WMSServiceDescription; ILayer wmsLayer = null; // add layers for the wms currently there will only be one. for (var i = 0; i <= serviceDesc.LayerDescriptionCount - 1; i++) { var layerDesc = serviceDesc.LayerDescription[i]; var grpLayer = wmsMapLayer.CreateWMSGroupLayers(layerDesc); for (var j = 0; j <= grpLayer.Count - 1; j++) { wmsLayer = wmsMapLayer; wmsMapLayer.Name = idahoId; } } // turn on sub layers, add it to arcmap and move it to top of TOC // SublayerVisibleOn(wmsLayer); groupLayer.Add(wmsLayer); // turn on sub layers, add it to arcmap and move it to top of TOC ArcMap.Document.AddLayer(groupLayer); ArcMap.Document.FocusMap.MoveLayer(groupLayer, 0); }
public void TestFindAddressCandidatesWithEmptyInput() { BindRunTime(); IPropertySet addressObj = new PropertySetClass(); BNG_Locator bng = new BNG_Locator(); IArray matches = bng.FindAddressCandidates(addressObj); Assert.IsTrue(matches.Count == 0); }
/// <summary> /// 连接到WMS服务器,载入WMS图层 /// </summary> /// <param name="axMapControl1">axMapControl控件</param> /// <param name="url">WMS服务器地址</param> public static void Connect2WMS(AxMapControl axMapControl1, string url) { #region 初始化环境 IPropertySet pPropertyset = new PropertySetClass(); pPropertyset.SetProperty("url", url); IWMSConnectionName pWMSConnectionName = new WMSConnectionNameClass(); pWMSConnectionName.ConnectionProperties = pPropertyset; ILayerFactory pLayerFactory = new EngineWMSMapLayerFactoryClass();//Provides access to members that control the creation of layers through a factory. IWMSGroupLayer pWmsMapLayer = new WMSMapLayerClass(); IDataLayer pDataLayer = pWmsMapLayer as IDataLayer; pDataLayer.Connect(pWMSConnectionName as IName); IWMSServiceDescription pWmsServiceDesc = pWmsMapLayer.WMSServiceDescription; #endregion #region 获取WMS图层 for (int i = 0; i < pWmsServiceDesc.LayerDescriptionCount; i++) { IWMSLayerDescription pWmsLayerDesc = pWmsServiceDesc.get_LayerDescription(i); ILayer pNewLayer = null; if (pWmsLayerDesc.LayerDescriptionCount == 0) { IWMSLayer pWmsLayer = pWmsMapLayer.CreateWMSLayer(pWmsLayerDesc); pNewLayer = pWmsLayer as ILayer; } else { IWMSGroupLayer pWmsGroupLayer = pWmsMapLayer.CreateWMSGroupLayers(pWmsLayerDesc); for (int j = 0; j < pWmsGroupLayer.Count; j++) { ILayer layer = pWmsGroupLayer.get_Layer(j); if (layer.Name != "admin") { pWmsMapLayer.InsertLayer(layer, 0); layer.Visible = true; } } } } #endregion #region 收尾工作 ILayer pLayer = pWmsMapLayer as ILayer; pLayer.Name = pWmsServiceDesc.WMSTitle; pLayer.Visible = true; axMapControl1.AddLayer(pLayer, 0); IEnvelope pEnv = axMapControl1.FullExtent; pEnv.Expand(0.8, 0.8, true); axMapControl1.Extent = pEnv; #endregion }
public override void OnClick() { if (m_pAOIPanel.CurrentJob != null) { //show form AddressDialog pAddressDialog = new AddressDialog(); if (pAddressDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ILocatorManager pLocatorMgr = new LocatorManagerClass(); ILocatorWorkspace pLocatorWS = pLocatorMgr.GetLocatorWorkspaceFromPath(m_strWorkspace); IAddressGeocoding pLocator = (IAddressGeocoding)pLocatorWS.GetLocator(m_strLocator); IPropertySet addressProperties = new PropertySetClass(); addressProperties.SetProperty("Street", pAddressDialog.street); IPropertySet matchProperties = pLocator.MatchAddress(addressProperties); if(pLocator.MatchFields.FieldCount == 0) { System.Windows.Forms.MessageBox.Show("No address found"); return; } IPoint pPoint = null; for(int i = 0; i < pLocator.MatchFields.FieldCount; i++) { if(pLocator.MatchFields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry) { object pObject = matchProperties.GetProperty(pLocator.MatchFields.get_Field(i).Name); if(pObject is IPoint) pPoint = (IPoint) pObject; } } //calculate AOI ITopologicalOperator pTopo = (ITopologicalOperator)pPoint; IGeometry pGeom = pTopo.Buffer(100); IEnvelope pMyAOI = pGeom.Envelope; m_pAOIPanel.CurrentAOI = CreatePolyFromEnv(pMyAOI); IEnvelope pEnv = pGeom.Envelope; pEnv.Expand(2, 2, true); m_hookHelper.ActiveView.Extent = pEnv; m_hookHelper.ActiveView.Refresh(); } } }
//not finished public static void BurstFindValves() { // run a FindPath between 2 flags, create a polyline from the results //��Ҫdesktop������ /* INetworkAnalysisExt pNetAnalysisExt; INetworkAnalysisExtFlags pNetAnalysisExtFlags; INetworkAnalysisExtBarriers pNetAnalysisExtBarriers; INetworkAnalysisExtResults pNetAnalysisExtResults; */ string valvelayername = "Water Fixtures"; string waterlinelayername = "Water Lines"; string waternetworkname = "Water_Network"; INetworkCollection pNetworkCollection; IFeatureDataset pFeatureDataSet; IWorkspaceFactory pWSF=new SdeWorkspaceFactoryClass(); IPropertySet pPropset=new PropertySetClass(); IFeatureWorkspace pFeatureWorkspace=pWSF.Open(pPropset,0) as IFeatureWorkspace; INetwork pNetwork; IGeometricNetwork pGeometricNetwork; pFeatureDataSet = pFeatureWorkspace.OpenFeatureDataset("datasetName"); pNetworkCollection=pFeatureDataSet as INetworkCollection; pGeometricNetwork=pNetworkCollection.get_GeometricNetworkByName("networkname"); pNetwork=pGeometricNetwork.Network; IEdgeFlagDisplay pEdgeFlagDisplay; IFlagDisplay pFlagDisplay; IEdgeFlag pEdgeFlag; INetFlag pNetFlag; //����һ��flag pEdgeFlag=new EdgeFlagClass(); pNetFlag=pEdgeFlag as INetFlag; IFeatureLayer pFeatLayerValves; IFeatureLayer pFeatLayerWaterLines; UID pID=new UIDClass(); }
//Create connection property set for Tracking Server private IPropertySet CreateTrackingServerConnectionProperties() { IPropertySet connectionProperties = new PropertySetClass(); connectionProperties.SetProperty("SERVERNAME", TS_SERVER_NAME); connectionProperties.SetProperty("AMS_CONNECTION_NAME", "Sample TS Connection"); //This is the standard AMS connection editor, this would only be different if you wrote your own connector connectionProperties.SetProperty("AMS_CONNECTOR_EDITOR", "{1C6BA545-2F59-11D5-B7E2-00010265ADC5}"); //This is the standard AMS connector, this would only be different if you wrote your own connector connectionProperties.SetProperty("AMS_CONNECTOR", "{F6FC70F5-5778-11D6-B841-00010265ADC5}"); connectionProperties.SetProperty("AMS_USER_NAME", ""); connectionProperties.SetProperty("TMS_USER_PWD", ""); return connectionProperties; }
private void GeocodeAddress() { // Get the locator System.Object obj = Activator.CreateInstance(Type.GetTypeFromProgID("esriLocation.LocatorManager")); ILocatorManager2 locatorManager = obj as ILocatorManager2; ILocatorWorkspace locatorWorkspace = locatorManager.GetLocatorWorkspaceFromPath(@"C:\California_fgdb.gdb"); ILocator locator = locatorWorkspace.GetLocator("California_city_state_zip_94_new"); // Set up the address properties IAddressInputs addressInputs = locator as IAddressInputs; IFields addressFields = addressInputs.AddressFields; IPropertySet addressProperties = new PropertySetClass(); addressProperties.SetProperty(addressFields.get_Field(0).Name, this.AddressTextBox.Text); addressProperties.SetProperty(addressFields.get_Field(1).Name, this.CityTextBox.Text); addressProperties.SetProperty(addressFields.get_Field(2).Name, this.StateTextBox.Text); addressProperties.SetProperty(addressFields.get_Field(3).Name, this.ZipTextBox.Text); // Match the Address IAddressGeocoding addressGeocoding = locator as IAddressGeocoding; IPropertySet resultSet = addressGeocoding.MatchAddress(addressProperties); // Print out the results object names, values; resultSet.GetAllProperties(out names, out values); string[] namesArray = names as string[]; object[] valuesArray = values as object[]; int length = namesArray.Length; IPoint point = null; for (int i = 0; i < length; i++) { if (namesArray[i] != "Shape") this.ResultsTextBox.Text += namesArray[i] + ": " + valuesArray[i].ToString() + "\n"; else { if (point != null && !point.IsEmpty) { point = valuesArray[i] as IPoint; this.ResultsTextBox.Text += "X: " + point.X + "\n"; this.ResultsTextBox.Text += "Y: " + point.Y + "\n"; } } } this.ResultsTextBox.Text += "\n"; }
public IFeatureLayer OracleQueryLayer() { // 创建SqlWorkspaceFactory的对象 Type pFactoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SqlWorkspaceFactory"); IWorkspaceFactory pWorkspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(pFactoryType); // 构造连接数据库的参数 IPropertySet pConnectionProps = new PropertySetClass(); pConnectionProps.SetProperty("dbclient", "Oracle11g"); pConnectionProps.SetProperty("serverinstance", "esri"); pConnectionProps.SetProperty("authentication_mode", "DBMS"); pConnectionProps.SetProperty("user", "scott"); pConnectionProps.SetProperty("password", "arcgis"); // 打开工作空间 IWorkspace workspace = pWorkspaceFactory.Open(pConnectionProps, 0); ISqlWorkspace pSQLWorkspace = workspace as ISqlWorkspace; //获取数据库中的所有表的名称 //IStringArray pStringArray= pSQLWorkspace.GetTables(); //for (int i = 0; i < pStringArray.Count; i++) //{ // MessageBox.Show(pStringArray.get_Element(i)); //} // 构造过滤条件 SELECT * FROM PointQueryLayer IQueryDescription queryDescription = pSQLWorkspace.GetQueryDescription("SELECT * FROM TEST"); ITable pTable = pSQLWorkspace.OpenQueryClass("QueryLayerTest", queryDescription); IFeatureLayer pFeatureLayer = new FeatureLayerClass(); pFeatureLayer.FeatureClass = pTable as IFeatureClass; return pFeatureLayer; }
public void TestFindAddressCandidatesCannotMatchAddress(string address) { BindRunTime(); // Get the input from the IPropertySet object names = null; object values = null; IPropertySet addressObj = new PropertySetClass(); names = new string[] { "Single Line Address" }; // Get centre point of Envelope for geocode location // Workaround for currnet non Point geometry issue values = new object[] { address }; addressObj.SetProperties(names, values); BNG_Locator bng = new BNG_Locator(); IArray matches = bng.FindAddressCandidates(addressObj); Assert.IsTrue(matches.Count == 0); }
/// <summary> /// 设置SDE连接属性 /// </summary> /// <params name="ChkSdeLinkModle"></params> /// <returns>IPropertySet</returns> public static IPropertySet ConnectSDE(bool ChkSdeLinkModle) { //定义一个属性 IPropertySet Propset = new PropertySetClass(); if (ChkSdeLinkModle == true) // 采用SDE连接 { string[] str = File.ReadAllLines(Application.StartupPath + @"\ConfigDatabaseGIS.ini"); for (int i = 0; i < str.Length; i++) { string key = str[i].Substring(0, str[i].IndexOf('=')); string value = str[i].Substring(str[i].IndexOf('=') + 1); Propset.SetProperty(key, value); } ////设置数据库服务器名 //Propset.SetProperty("SERVER", "10.64.192.51"); ////设置SDE的端口,这是安装时指定的,默认安装时"port:5151" //Propset.SetProperty("INSTANCE", "sde:sqlserver:10.64.192.51");// ////DBCLIENT数据库平台 //Propset.SetProperty("DBCLIENT", "sqlserver"); ////DB_CONNECTION_PROPERTIES //Propset.SetProperty("DB_CONNECTION_PROPERTIES", "10.64.192.51"); ////设置数据库的名字,只有SQL Server Informix 数据库才需要设置 //Propset.SetProperty("DATABASE", "GasEarlyWarningGIS"); //////IS_GEODATABASE ////Propset.SetProperty("IS_GEODATABASE", "true"); //////AUTHENTICATION_MODE ////Propset.SetProperty("AUTHENTICATION_MODE", "DBMS"); ////SDE的用户名 //Propset.SetProperty("USER", "sde"); ////密码 //Propset.SetProperty("PASSWORD", "sde"); ////SDE的版本,在这为默认版本 //Propset.SetProperty("VERSION", "SDE.DEFAULT"); } else // 直接连接 { //设置数据库服务器名,如果是本机可以用"sde:sqlserver:.",直接连接会弹出选择数据库对话框,要求填入用户名密码 Propset.SetProperty("INSTANCE", "sde:sqlserver:xxsde"); } return Propset; }
public static int CreateAndGetOID() { BlobberRepository repository = new BlobberRepository(); repository.StartEdit(); Blobber b = repository.Create(); b.BlobberId = BLOBBER_ID; IPropertySet properties = new PropertySetClass(); properties.SetProperty("VALUE1", BLOBBER_VALUE_1); properties.SetProperty("VALUE2", BLOBBER_VALUE_2); properties.SetProperty("VALUE3", BLOBBER_VALUE_3); b.Properties = properties; b.Store(); repository.StopEdit(true); return b.ObjectId; }
public static IPropertySet PropertySetFromString(String propertySetText) { if (String.IsNullOrEmpty(propertySetText)) throw new ArgumentNullException("propertySetText"); IPropertySet propertySet = new PropertySetClass(); String[] properties = propertySetText.Split(new[] { ';' }); for (int i = 0; i < properties.Count(); i++) { if (String.IsNullOrEmpty(properties[i])) continue; String[] propertyParts = properties[i].Split(new[] { '=' }); // Remove [ ] String name = propertyParts[0].Substring(1, propertyParts[0].Length - 2); String value = propertyParts[1]; propertySet.SetProperty(name, value); } return propertySet; }
public static IWorkspace WorkgroupArcSdeWorkspaceFromPropertySet() { IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("SERVER", "172.25.3.110"); propertySet.SetProperty("INSTANCE", "sde:oracle11g:sigprod_oda"); propertySet.SetProperty("USER", "TLOB"); propertySet.SetProperty("PASSWORD", "TeleobservacionSGC"); propertySet.SetProperty("VERSION", "SDE.DEFAULT"); propertySet.SetProperty("AUTHENTICATION_MODE", "DBMS"); try { Type factoryType = Type.GetTypeFromProgID( "esriDataSourcesGDB.SdeWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance (factoryType); return workspaceFactory.Open(propertySet, 0); } catch (Exception ex) { MessageBox.Show("Error conectandose a la base de datos" + ex.Message); return null; } }
/// <summary> /// /// </summary> /// <param name="server"></param> /// <param name="instance"></param> /// <param name="user"></param> /// <param name="password"></param> /// <param name="database"></param> /// <param name="version"></param> /// <param name="sdeFullPath">c:\\temp\\Sample.sde</param> /// <returns></returns> public IWorkspaceName CreateConnectionFile(string server, string instance, string user, string password, string database, string version, string sdeFullPath) { if (sdeFullPath == null) { } string sdePathWithSlash = ""; string sdeFileName = ""; string[] pathSplit = sdeFullPath.Split('\\'); sdePathWithSlash = pathSplit[0] + "\\\\" + pathSplit[1] + "\\\\"; sdeFileName = pathSplit[2]; MessageBox.Show("line 231 WspM "+sdePathWithSlash + "--" + sdeFileName); IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("SERVER", server); propertySet.SetProperty("INSTANCE", instance); propertySet.SetProperty("DATABASE", database); propertySet.SetProperty("USER", user); propertySet.SetProperty("PASSWORD", password); propertySet.SetProperty("VERSION", version); IWorkspaceFactory2 workspaceFactory = (IWorkspaceFactory2)new SdeWorkspaceFactoryClass(); return workspaceFactory.Create(sdePathWithSlash, sdeFileName, propertySet, 0); }
//////////////////////////////////////////////////////////////////////// // METHOD: CreateChildVersion private bool CreateChildVersion(ref IJTXJob pJob) { IVersion pNewVersion = null; try { string strVersionName = pJob.VersionName; int index = strVersionName.IndexOf(".", 0); if (index >= 0) { strVersionName = strVersionName.Substring(index + 1); } pJob.VersionName = strVersionName; pNewVersion = pJob.CreateVersion(esriVersionAccess.esriVersionAccessPublic); if (pNewVersion == null) { m_ipDatabase.LogMessage(3, 1000, "Unable to create version for child job ID: " + pJob.ID); } else { IPropertySet pOverrides = new PropertySetClass(); pOverrides.SetProperty("[VERSION]", pNewVersion.VersionName); JobUtilities.LogJobAction(m_ipDatabase, pJob, Constants.ACTTYPE_CREATE_VERSION, "", pOverrides); JTXUtilities.SendNotification(Constants.NOTIF_VERSION_CREATED, m_ipDatabase, pJob, pOverrides); } } catch (Exception ex) { m_ipDatabase.LogMessage(3, 1000, "Unable to create version for child job ID: " + pJob.ID + ". ERROR: " + ex.Message); } finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(pNewVersion); } return true; }
//////////////////////////////////////////////////////////////////////// // METHOD: CreateDependencyOnParentJob private void CreateDependencyOnParentJob(IJTXJobDependencies dependencyManager, IJTXJob2 pParentJob, int childJobID) { IJTXJobDependency dependency = dependencyManager.CreateDependency(pParentJob.ID); dependency.DepJobID = childJobID; dependency.DepOnType = jtxDependencyType.jtxDependencyTypeStatus; IJTXStatus statusType = null; if (!m_paramHasStatusType) statusType = m_ipDatabase.ConfigurationManager.GetStatus("Closed"); else statusType = m_ipDatabase.ConfigurationManager.GetStatus(m_paramStatusType); dependency.DepOnValue = statusType.ID; dependency.HeldOnType = jtxDependencyType.jtxDependencyTypeStep; IJTXWorkflowExecution parentWorkflow = pParentJob as IJTXWorkflowExecution; int[] currentSteps = parentWorkflow.GetCurrentSteps(); int dependentStep = currentSteps[0]; if (m_paramDependNextStep) { IJTXWorkflowConfiguration workflowConf = pParentJob as IJTXWorkflowConfiguration; try { dependentStep = workflowConf.GetAllNextSteps(currentSteps[0])[0]; } catch (IndexOutOfRangeException) { MessageBox.Show(Properties.Resources.NoNextStep, Properties.Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } dependency.HeldOnValue = dependentStep; dependency.Store(); IPropertySet props = new PropertySetClass(); props.SetProperty("[DEPENDENCY]", dependency.ID); JobUtilities.LogJobAction(m_ipDatabase, pParentJob, Constants.ACTTYPE_ADD_DEPENDENCY, "", props); }
public void Init() { // Open workspace and feature class. IWorkspaceFactory wksf = new PostGisWorkspaceFactory(); //Open from zigFile //ws = wksf.OpenFromFile(@"C:\ziggis\ZigGis\example.zig", 0); //Open from PropertySet IPropertySet ps = new PropertySetClass(); ps.SetProperty("server", "localhost"); ps.SetProperty("database", "TUTORIAL"); ps.SetProperty("user", "psqluser"); ps.SetProperty("password", "psqluser"); ps.SetProperty("port", "5432"); ps.SetProperty("configfile", @"C:\ziggis\ZigGis\logging.config"); ws = wksf.Open(ps, 0); IFeatureWorkspace fwks = ws as IFeatureWorkspace; fc = fwks.OpenFeatureClass("zone"); // Create the new layer (default renderer is ISimpleRenderer) layer = new PostGisFeatureLayer(); layer.FeatureClass = fc; layer.Name = fc.AliasName; }
/// <summary> /// This method searches for the record of the given zipcode and retunes the information as a PropertySet. /// </summary> /// <param name="zipCode"></param> /// <returns>a PropertySet encapsulating the weather information for the given weather item.</returns> public IPropertySet GetWeatherItem(long zipCode) { DataRow r = m_table.Rows.Find(zipCode); if(null == r) return null; IPropertySet propSet = new PropertySetClass(); propSet.SetProperty( "ID", r[0]); propSet.SetProperty( "ZIPCODE", r[1]); propSet.SetProperty( "CITYNAME", r[2]); propSet.SetProperty( "LAT", r[3]); propSet.SetProperty( "LON", r[4]); propSet.SetProperty( "TEMPERATURE", r[5]); propSet.SetProperty( "CONDITION", r[6]); propSet.SetProperty( "ICONNAME", r[7]); propSet.SetProperty( "ICONID", r[8]); propSet.SetProperty( "DAY", r[9]); propSet.SetProperty( "DATE", r[10]); propSet.SetProperty( "LOW", r[11]); propSet.SetProperty( "HIGH", r[12]); propSet.SetProperty( "UPDATEDATE", r[14]); return propSet; }
private void listProjects_SelectedIndexChanged(object sender, EventArgs e) { // Need to clear the versions when selected this.listVersions.DataSource = null; string selectedProject = null; try { selectedProject = (string)this.listProjects.SelectedValue; } catch { return; } if (selectedProject == null) { return; } // Prompt the user to select a version. Open the database IPropertySet connectionProperties = new PropertySetClass(); connectionProperties.SetProperty("SERVER", "malachite\\azgsgeodatabases"); connectionProperties.SetProperty("INSTANCE", "sde:sqlserver:malachite\\azgsgeodatabases"); connectionProperties.SetProperty("DATABASE", selectedProject); connectionProperties.SetProperty("AUTHENTICATION_MODE", "OSA"); connectionProperties.SetProperty("VERSION", "dbo.Default"); IWorkspaceFactory wsFact = new SdeWorkspaceFactoryClass(); IVersionedWorkspace vWs = (IVersionedWorkspace)wsFact.Open(connectionProperties, 0); // Build a DataTable to bind to the listbox control DataTable verTable = new DataTable(); DataColumn verName = new DataColumn(); verName.ColumnName = "VersionName"; verName.DataType = typeof(string); verTable.Columns.Add(verName); IEnumVersionInfo theseVersions = vWs.Versions; IVersionInfo aVersion = theseVersions.Next(); while (aVersion != null) { string thisVersionName = (string)aVersion.VersionName; string[] Split = thisVersionName.Split(new char[] { '.' }); verTable.Rows.Add(Split[1]); aVersion = theseVersions.Next(); } this.listVersions.DataSource = verTable; this.listVersions.DisplayMember = "VersionName"; this.listVersions.ValueMember = "VersionName"; }
/// <summary> /// Add WMS map service layer to map /// </summary> /// <param name="msi">Map service information</param> private void AddLayerWMS(esri.gpt.csw.MapServiceInfo msi, Boolean fromServerUrl) { if (msi == null) { throw new ArgumentNullException(); } try { string url = AppendQuestionOrAmpersandToUrlString(msi.Server); // append serviceParam to server url // todo: does msi.ServiceParam have a leading "?" or "&"? if (msi.ServiceParam.Length > 0 || !fromServerUrl) { url = url + msi.ServiceParam; url = AppendQuestionOrAmpersandToUrlString(url); } IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("URL", url); IMxDocument mxDoc = (IMxDocument)m_application.Document; IMap map = (IMap)mxDoc.FocusMap; IActiveView activeView = (IActiveView)map; IWMSGroupLayer wmsGroupLayer = (IWMSGroupLayer)new WMSMapLayerClass(); IWMSConnectionName wmsConnectionName = new WMSConnectionName(); wmsConnectionName.ConnectionProperties = propertySet; // connect to wms service IDataLayer dataLayer; bool connected = false; try { dataLayer = (IDataLayer)wmsGroupLayer; IName connName = (IName)wmsConnectionName; connected = dataLayer.Connect(connName); } catch (Exception ex) { ShowErrorMessageBox (StringResources.ConnectToMapServiceFailed + "\r\n" + ex.Message); connected = false; } if (!connected) return; // get service description out of the layer. the service description contains // inforamtion about the wms categories and layers supported by the service IWMSServiceDescription wmsServiceDesc = wmsGroupLayer.WMSServiceDescription; IWMSLayerDescription wmsLayerDesc; ILayer newLayer; ILayer layer; IWMSLayer newWmsLayer; IWMSGroupLayer newWmsGroupLayer; /* for (int i = 0; i < wmsServiceDesc.LayerDescriptionCount; i++) { newLayer = null; wmsLayerDesc = wmsServiceDesc.get_LayerDescription(i); if (wmsLayerDesc.LayerDescriptionCount == 0) { // wms layer newWmsLayer = wmsGroupLayer.CreateWMSLayer(wmsLayerDesc); newLayer = (ILayer)newWmsLayer; if (newLayer == null) { throw new Exception(StringResources.CreateWmsLayerFailed); }; } else { // wms group layer newWmsGroupLayer = wmsGroupLayer.CreateWMSGroupLayers(wmsLayerDesc); newLayer = (ILayer)newWmsGroupLayer; if (newLayer == null) { throw new Exception(StringResources.CreateWmsGroupLayerFailed); } } // add newly created layer // if(wmsGroupLayer.get_Layer(i).Name != newLayer.Name) wmsGroupLayer.InsertLayer(newLayer, 0); }*/ // configure the layer before adding it to the map layer = (ILayer)wmsGroupLayer; layer.Name = wmsServiceDesc.WMSTitle; ExpandLayer(layer, true); SetLayerVisibility(layer, true); // add to focus map map.AddLayer(layer); return; } catch (Exception ex) { ShowErrorMessageBox (StringResources.AddWmsLayerFailed + "\r\n" + ex.Message); } }
private void AddAGSService(string fileName) { try { IMxDocument mxDoc = (IMxDocument)m_application.Document; IMap map = (IMap)mxDoc.FocusMap; IActiveView activeView = (IActiveView)map; bool isAlreadyInMap = false; if (isAlreadyInMap) { ShowErrorMessageBox(StringResources.MapServiceLayerAlreadyExistInMap); return; } else { if (fileName.ToLower().Contains("http") && !fileName.ToLower().Contains("arcgis/rest")) { if(fileName.EndsWith("MapServer")) fileName = fileName.Remove(fileName.LastIndexOf("MapServer")); String[] s = fileName.ToLower().Split(new String[]{"/services"}, StringSplitOptions.RemoveEmptyEntries); IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("URL", s[0] + "/services"); // fileName IMapServer mapServer = null; IAGSServerConnectionFactory pAGSServerConFactory = new AGSServerConnectionFactory(); IAGSServerConnection agsCon = pAGSServerConFactory.Open(propertySet,0); IAGSEnumServerObjectName pAGSSObjs = agsCon.ServerObjectNames; IAGSServerObjectName pAGSSObj = pAGSSObjs.Next(); while (pAGSSObj != null) { if(pAGSSObj.Type=="MapServer" && pAGSSObj.Name.ToLower() == s[1].TrimStart('/').TrimEnd('/')){ break; } pAGSSObj = pAGSSObjs.Next(); } IName pName = (IName) pAGSSObj; IAGSServerObject pAGSO = (IAGSServerObject) pName.Open(); mapServer = (IMapServer) pAGSO; IPropertySet prop = new PropertySetClass(); prop.SetProperty("URL", fileName); prop.SetProperty("Name",pAGSSObj.Name); IMapServerLayer layer = new MapServerLayerClass(); layer.ServerConnect(pAGSSObj,mapServer.get_MapName(0)); mxDoc.AddLayer((ILayer)layer); } else { IGxFile pGxFile; if (fileName.ToLower().EndsWith(".tif")) { IRasterLayer pGxLayer = (IRasterLayer)new RasterLayer(); pGxLayer.CreateFromFilePath(fileName); if (pGxLayer.Valid) { map.AddLayer((ILayer)pGxLayer); } } else { if (fileName.ToLower().Contains("http") && fileName.ToLower().Contains("arcgis/rest")) { String[] s = fileName.ToLower().Split(new String[] { "/rest" }, StringSplitOptions.RemoveEmptyEntries); IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("URL", s[0] + "/services"); // fileName IMapServer mapServer = null; IAGSServerConnectionFactory pAGSServerConFactory = new AGSServerConnectionFactory(); IAGSServerConnection agsCon = pAGSServerConFactory.Open(propertySet, 0); IAGSEnumServerObjectName pAGSSObjs = agsCon.ServerObjectNames; IAGSServerObjectName pAGSSObj = pAGSSObjs.Next(); String[] parts = s[1].ToLower().Split(new String[] { "/" }, StringSplitOptions.RemoveEmptyEntries); while (pAGSSObj != null) { if (pAGSSObj.Type == "MapServer" && pAGSSObj.Name.ToLower() == parts[1]) { break; } pAGSSObj = pAGSSObjs.Next(); } IName pName = (IName)pAGSSObj; IAGSServerObject pAGSO = (IAGSServerObject)pName.Open(); mapServer = (IMapServer)pAGSO; IPropertySet prop = new PropertySetClass(); prop.SetProperty("URL", fileName); prop.SetProperty("Name", pAGSSObj.Name); IMapServerLayer layer = new MapServerLayerClass(); layer.ServerConnect(pAGSSObj, mapServer.get_MapName(0)); mxDoc.AddLayer((ILayer)layer); } else { IGxLayer pGxLayer = new GxLayer(); pGxFile = (GxFile)pGxLayer; pGxFile.Path = fileName; if (pGxLayer.Layer != null) { map.AddLayer(pGxLayer.Layer); } } } } } } catch (Exception ex) { ShowErrorMessageBox(StringResources.AddArcGISLayerFailed + "\r\n" + ex.Message); } }
public IWorkspace CreateWorkspaceSDE(string server, string instance, string database, string version, string user, string password) { IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass(); IPropertySet propertySet = new PropertySetClass(); //create version for editting //TnUtilities utilities = new TnUtilities(); IWorkspace workspace = null; //utilities.StartService("esri_sde", 2000); propertySet.SetProperty("SERVER", server); propertySet.SetProperty("INSTANCE", instance); propertySet.SetProperty("DATABASE", database); propertySet.SetProperty("VERSION", version); propertySet.SetProperty("USER", user); propertySet.SetProperty("PASSWORD", password); //if (authentication_mode != "OSA" && authentication_mode != "osa") //{ // propertySet.SetProperty("USER", user); // propertySet.SetProperty("PASSWORD", password); //} //else if (authentication_mode == "OSA" || authentication_mode == "osa") //{ // propertySet.SetProperty("AUTHENTICATION_MODE", authentication_mode); //} //else //{ // MessageBox.Show("Chua xac dinh duoc Authentication_mode"); //} //if (version == "sde.DEFAULT") //{ // Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"); // workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); //} //if (version == "dbo.DEFAULT") //{ // propertySet.SetProperty("VERSION", version); //} //else //{ Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"); workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); //} try { workspace = workspaceFactory.Open(propertySet, 0); } catch (Exception ex){MessageBox.Show(string.Format("line 94 WorkspaceManagement:\n {0}",ex)); } //if (workspace.IsBeingEdited() != true) //{ // workspaceEdit.StartEditing(true); // workspaceEdit.StartEditOperation(); //} return workspace; }
/// <summary> /// tạo file connection *.sde /// </summary> /// <param name="server"></param> /// <param name="instance"></param> /// <param name="user"></param> /// <param name="password"></param> /// <param name="database"></param> /// <param name="version"></param> /// <param name="sdePathWithSlash">c:\\temp\\</param> /// <param name="sdeFileName">Sample.sde</param> /// <returns></returns> public IWorkspaceName CreateConnectionFile(string server, string instance, string user, string password, string database, string version,string sdePathWithSlash,string sdeFileName) { IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("SERVER", server); propertySet.SetProperty("INSTANCE", instance); propertySet.SetProperty("DATABASE", database); propertySet.SetProperty("USER", user); propertySet.SetProperty("PASSWORD", password); propertySet.SetProperty("VERSION", version); IWorkspaceFactory2 workspaceFactory = (IWorkspaceFactory2)new SdeWorkspaceFactoryClass(); return workspaceFactory.Create(sdePathWithSlash, sdeFileName, propertySet, 0); }
public azgsSqlDatabaseChooser() { InitializeComponent(); // Populate the listbox // Build a DataTable to bind to the listbox control DataTable projectTable = new DataTable(); DataColumn projName = new DataColumn(); projName.ColumnName = "ProjectName"; projName.DataType = typeof(string); DataColumn dbName = new DataColumn(); dbName.ColumnName = "DatabaseName"; dbName.DataType = typeof(string); projectTable.Columns.Add(projName); projectTable.Columns.Add(dbName); // Populate the DataTable - Right now this is pinging a DB on malachite IPropertySet connectionProperties = new PropertySetClass(); connectionProperties.SetProperty("SERVER", "malachite\\azgsgeodatabases"); connectionProperties.SetProperty("INSTANCE", "sde:sqlserver:malachite\\azgsgeodatabases"); connectionProperties.SetProperty("DATABASE", "AzgsIndex"); connectionProperties.SetProperty("AUTHENTICATION_MODE", "OSA"); connectionProperties.SetProperty("VERSION", "dbo.Default"); try { IWorkspaceFactory wsFact = new SdeWorkspaceFactoryClass(); IWorkspace theWs = wsFact.Open(connectionProperties, 0); // Open the table in the repository database ITable ProjectListingsTable = commonFunctions.OpenTable(theWs, "ProjectDatabases"); // Get all the records into a sorted cursor ITableSort projSorter = new TableSortClass(); projSorter.Table = ProjectListingsTable; projSorter.QueryFilter = null; projSorter.Fields = "ProjectName"; projSorter.set_Ascending("ProjectName", true); projSorter.Sort(null); ICursor projCur = projSorter.Rows; //ProjectListingsTable.Search(null, false); // Loop through the cursor and add records to the DataTable IRow projRow = projCur.NextRow(); while (projRow != null) { projectTable.Rows.Add((String)projRow.get_Value(ProjectListingsTable.FindField("ProjectName")), (String)projRow.get_Value(ProjectListingsTable.FindField("DatabaseName"))); projRow = projCur.NextRow(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(projCur); // Bind the DataTable to the control this.listProjects.DataSource = projectTable; this.listProjects.DisplayMember = "ProjectName"; this.listProjects.ValueMember = "DatabaseName"; this.listProjects.SelectedItem = null; this.listVersions.DataSource = null; } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace); return; } }