public override void OnClick() { //设置成果库连接信息 //获取树节点上工程节点的连接IP信息 DevComponents.AdvTree.Node SelNode = m_Hook.ProjectTree.SelectedNode; string NodeType = SelNode.DataKey.ToString().Trim(); if (EnumTreeNodeType.DATABASE.ToString() == NodeType) { if (SelNode.Name == "文件连接") { XmlElement Ele = SelNode.Tag as XmlElement; if (Ele == null) { frmConSet frmconset = new frmConSet("", "", "", ""); frmconset.ShowDialog(); } else { string ConType = Ele.GetAttribute("实例名"); if (null == ConType || "" == ConType) { string ip = Ele.GetAttribute("服务器"); string id = Ele.GetAttribute("用户"); string password = Ele.GetAttribute("密码"); string metaConn = Ele.GetAttribute("MetaDBConn"); frmConSet frmconset = new frmConSet(ip, id, password, metaConn); frmconset.ShowDialog(); } } } else if (SelNode.Name == "空间连接") { } } }
public override void OnClick() { Exception eError = null; DevComponents.AdvTree.Node SelNode = m_Hook.ProjectTree.SelectedNode; if (SelNode.DataKey.ToString() == EnumTreeNodeType.DATACONNECT.ToString()) { //建立连接 if (SelNode.Name == "FileDBConnNode") { //文件连接 frmConSet frmconset = new frmConSet(); frmconset.ShowDialog(); } else if (SelNode.Name == "SpatialDBConnNode") { //空间连接 } } else if (SelNode.DataKey.ToString() == EnumTreeNodeType.DATABASE.ToString()) { //读取xml连接参数,连接库体 Exception ex = null; string ConType = SelNode.Name; if ("文件连接" == ConType) { //文件库连接 XmlElement Ele = SelNode.Tag as XmlElement; if (null == Ele) { return; } string ip = Ele.GetAttribute("服务器"); string id = Ele.GetAttribute("用户"); string password = Ele.GetAttribute("密码"); string dbConnStr = Ele.GetAttribute("MetaDBConn"); ModDBOperator.ConnectDB(dbConnStr, ip, id, password, out eError); if (eError != null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", eError.Message); return; } /////////////////////加载底图(2010.5.31临时添加)///////////////////////// //SysCommon.Gis.SysGisDataSet pSysGis = new SysCommon.Gis.SysGisDataSet(); //pSysGis.SetWorkspace(dbConnStr, SysCommon.enumWSType.PDB, out ex); //if (ex != null) //{ // SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "连接范围图层失败!"); // return; //} //IFeatureLayer featurelayer = new FeatureLayerClass(); //IFeatureClass featureclass = pSysGis.GetFeatureClass("ProjectRange", out ex); //if (ex != null) //{ // SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", ex.Message); // return; //} //featurelayer.FeatureClass = featureclass; //ILayer layer = featurelayer as ILayer; //layer.Name = "项目范围图"; //ModData.v_AppFileDB.MapControl.Map.AddLayer(layer); ////////////////////////////////////////////// } if (ConType == "空间连接") { //空间连接 } } }