/// <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 SetPhysicsDataSourceForm() { InitializeComponent(); //初始化加载配置文件中记录的信息 string strDbType = m_dIndex.GetDbValue("dbType"); //string strServerPath = m_dIndex.GetDbValue("dbServerPath"); //txtServer.Text = strServerPath; cboDataType.Text = strDbType; if (strDbType.Equals("SDE")) { labelX5.Text = "服务器:"; btnServer.Visible = false; btnServer.Enabled = false; //txtService.Enabled = true; txtDataBase.Enabled = true; txtUser.Enabled = true; txtPassWord.Enabled = true; //txtVersion.Enabled = true; m_wsType = enumWSType.SDE; txtDataBase.Text = m_dIndex.GetDbValue("dbServerName"); txtUser.Text = m_dIndex.GetDbValue("dbUser"); txtPassWord.Text = m_dIndex.GetDbValue("dbPassword"); txtService.Text = m_dIndex.GetDbValue("dbService"); txtVersion.Text = m_dIndex.GetDbValue("dbVersion"); } else if (strDbType.Equals("PDB")) { labelX5.Text = "数据库:"; btnServer.Visible = true; btnServer.Enabled = true; txtService.Enabled = false; txtUser.Enabled = false; txtDataBase.Enabled = false; txtPassWord.Enabled = false; txtVersion.Enabled = false; m_wsType = enumWSType.PDB; } else if (strDbType.Equals("GDB")) { labelX5.Text = "数据库:"; btnServer.Visible = true; btnServer.Enabled = true; txtService.Enabled = false; txtUser.Enabled = false; txtDataBase.Enabled = false; txtPassWord.Enabled = false; txtVersion.Enabled = false; m_wsType = enumWSType.GDB; } InitializeComDSname(); InitializeComboBox(); }
//数据源类型发生变化 private void cboDataType_SelectedIndexChanged(object sender, EventArgs e) { if (cboDataType.Text.Equals("SDE")) { labelX5.Text = "服务器名称:"; btnServer.Visible = false; btnServer.Enabled = false; txtServer.Text = ""; //txtService.Enabled = true; txtDataBase.Enabled = true; txtUser.Enabled = true; txtPassWord.Enabled = true; //txtVersion.Enabled = true; //if (comboBoxDsName.Items.Count > 0) //{ // comboBoxDsName.SelectedIndex = 0; //} m_wsType = enumWSType.SDE; } else if (cboDataType.Text.Equals("PDB")) { labelX5.Text = "数据库:"; btnServer.Visible = true; btnServer.Enabled = true; txtService.Enabled = false; txtUser.Enabled = false; txtDataBase.Enabled = false; txtPassWord.Enabled = false; txtVersion.Enabled = false; //if (comboBoxDsName.Items.Count > 0) //{ // comboBoxDsName.SelectedIndex = 0; //} m_wsType = enumWSType.PDB; } else if (cboDataType.Text.Equals("GDB")) { labelX5.Text = "数据库:"; btnServer.Visible = true; btnServer.Enabled = true; txtService.Enabled = false; txtUser.Enabled = false; txtDataBase.Enabled = false; txtPassWord.Enabled = false; txtVersion.Enabled = false; //if (comboBoxDsName.Items.Count > 0) //{ // comboBoxDsName.SelectedIndex = 0; //} m_wsType = enumWSType.GDB; } }
public override void OnClick() { if (m_Hook != null) { LogFile log = new LogFile(m_Hook.tipRichBox, m_Hook.strLogFilePath); if (log != null) { log.Writelog("加载数据目录"); } //根据连接的数据库信息 初始化数据单元树 InitDataUnitTree(); //加载数据 if (m_Hook.gisDataSet == null) { m_Hook.gisDataSet = new SysGisDataSet(); } if (m_Hook.gisDataSet.WorkSpace == null) { GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex(); string mypath = dIndex.GetDbValue("dbServerPath"); string dbType = dIndex.GetDbValue("dbType"); string dataBase = dIndex.GetDbValue("dbServerName"); string user = dIndex.GetDbValue("dbUser"); string password = dIndex.GetDbValue("dbPassword"); string service = dIndex.GetDbValue("dbService"); string version = dIndex.GetDbValue("dbVersion"); Exception eError = null; if (dbType.Equals("SDE")) { wsType = enumWSType.SDE; } else if (dbType.Equals("PDB")) { wsType = enumWSType.PDB; } else if (dbType.Equals("GDB")) { wsType = enumWSType.GDB; } IWorkspace pWorkspace = GetWorkspace(mypath, service, dataBase, user, password, version, wsType, out eError); } //索引树跳转到地图文档窗口 // m_Hook.IndextabControl.SelectedTab = m_Hook.IndextabControl.Tabs["PageIndex"]; } }
//数据源类型发生变化 private void cboDataType_SelectedIndexChanged(object sender, EventArgs e) { if (cboDataType.Text.Equals("SDE")) { labelX5.Text = "服务器:"; btnServer.Visible = false; btnServer.Enabled = false; txtService.Enabled = true; txtDataBase.Enabled = true; txtUser.Enabled = true; txtPassWord.Enabled = true; txtVersion.Enabled = true; m_wsType = enumWSType.SDE; } else if (cboDataType.Text.Equals("PDB")) { labelX5.Text = "数据库:"; btnServer.Visible = true; btnServer.Enabled = true; txtService.Enabled = false; txtUser.Enabled = false; txtDataBase.Enabled = false; txtPassWord.Enabled = false; txtVersion.Enabled = false; m_wsType = enumWSType.PDB; } else if (cboDataType.Text.Equals("GDB")) { labelX5.Text = "数据库:"; btnServer.Visible = true; btnServer.Enabled = true; txtService.Enabled = false; txtUser.Enabled = false; txtDataBase.Enabled = false; txtPassWord.Enabled = false; txtVersion.Enabled = false; m_wsType = enumWSType.GDB; } }
/// <summary> /// 检查用户登陆 /// </summary> /// <param name="name"></param> /// <param name="password"></param> /// <param name="gisDb"></param> /// <returns></returns> public static bool CheckLogin(string name, string password, ref SysGisDB gisDb, enumWSType wsType, out Exception eError) { eError = null; User user; bool result = false; try { if (gisDb == null) { gisDb = new SysGisDB(); switch (wsType) { case enumWSType.SDE: result = gisDb.SetWorkspace(Mod.Server, Mod.Instance, Mod.Database, Mod.User, Mod.Password, Mod.Version, out eError); break; case enumWSType.PDB: case enumWSType.GDB: result = gisDb.SetWorkspace(Mod.Server, wsType, out eError); break; default: break; } if (!result) { return(false); } } SysGisTable sysTable = new SysGisTable(gisDb); Dictionary <string, object> dicData = sysTable.GetRow("user_info", "NAME='" + name.ToLower() + "'", out eError); if (dicData != null && dicData.Count > 0) { user = new User(); user.IDStr = dicData["USERID"].ToString(); user.Name = dicData["NAME"].ToString(); user.TrueName = dicData["TRUTHNAME"].ToString(); user.Password = dicData["UPWD"].ToString(); user.SexInt = int.Parse(dicData["USEX"].ToString()); user.Position = dicData["UPOSITION"].ToString(); user.Remark = dicData["UREMARK"].ToString(); string aa = SysCommon.Authorize.AuthorizeClass.ComputerSecurity(password.ToLower()); if (user.Password.Equals(SysCommon.Authorize.AuthorizeClass.ComputerSecurity(password.ToLower()))) { Mod.v_AppUser = user; //读取系统权限XML XmlDocument docXml = new XmlDocument(); if (!File.Exists(Mod.m_SysXmlPath)) { return(false); } docXml.Load(Mod.m_SysXmlPath); Mod.v_SystemXml = docXml; Mod.v_ListUserPrivilegeID = GetUserPrivilege(user, gisDb, out eError); Mod.v_ListUserdataPriID = GetUserDataPri(user, gisDb, out eError); return(true); } } return(false); } catch (Exception ex) { eError = ex; return(false); } }
/// <summary> /// 得到工作空间 /// </summary> /// <param name="eError"></param> /// <returns></returns> public IWorkspace GetWorkspace(string server, string service, string dataBase, string user, string password, string version, enumWSType wsType, out Exception eError) { eError = null; bool result = false; if (m_Hook.gisDataSet == null) { m_Hook.gisDataSet = new SysGisDataSet(); } try { switch (wsType) { case enumWSType.SDE: result = m_Hook.gisDataSet.SetWorkspace(server, service, dataBase, user, password, version, out eError); break; case enumWSType.PDB: case enumWSType.GDB: result = m_Hook.gisDataSet.SetWorkspace(server, wsType, out eError); break; default: break; } if (result) { return(m_Hook.gisDataSet.WorkSpace); } else { return(null); } } catch (Exception ex) { eError = ex; return(null); } }