private void btnCreateSde_Click(object sender, EventArgs e) { setArcgis.init(); EngineDatabase engine = new EngineDatabase(); Db db = QuickConfig.Common.setXml.getConfig(ConfigName).Db; try { setDB setdb = new setDB(db.DbSystemUser.User, db.DbSystemUser.Password, db.Datasource); foreach (Control ctl in dbControlList) { if (ctl is gdbChoose && ((gdbChoose)ctl).Check == true) { string Name = ((gdbChoose)ctl).Name; DbSdeUser dbsdeuser = db.DbSdeUserList.Find((DbSdeUser ds) => ds.Name == Name); if (setdb.isUserExist(dbsdeuser.User)) { // MessageBox.Show("现势库已存在"); if (MessageBox.Show("现势库已存在,是否删除已有的现势库", "确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { bool res = setdb.deleteUser(dbsdeuser.User); if (res == true) { MessageBox.Show("现势库删除成功!"); } else { MessageBox.Show("现势库删除失败!"); } } } else { string ans1 = engine.createSDE("Oracle", db.Datasource, db.DbSystemUser.User, db.DbSystemUser.Password, dbsdeuser.User, dbsdeuser.Password, dbsdeuser.Tablespace, Common.getSdeEcpFile()); setdb.grantUser(dbsdeuser.User); MessageBox.Show("现势库创建结果如下:\r\n" + ans1); } } } } catch (Exception eg) { MessageBox.Show(eg.Message.ToString()); } MessageBox.Show("企业空间库操作结束"); }
private void btnCreateUser_Click(object sender, EventArgs e) { if (MessageBox.Show("创建用户会先drop掉原有用户和用户对象\r\n,请先备份数据库!\r\n继续请点击确定,放弃请点击取消。", "创建用户", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Cancel) { return; } Db db = QuickConfig.Common.setXml.getConfig(ConfigName).Db; try { setDB setdb = new setDB(db.DbSystemUser.User, db.DbSystemUser.Password, db.Datasource); string ansStr = "开始创建用户\r\n"; foreach (Control ctl in dbControlList) { if (ctl is dmpChoose && ((dmpChoose)ctl).Check == true) { string Name = ((dmpChoose)ctl).Name; DbUser dbuser = db.DbUserList.Find((DbUser ds) => ds.Name == Name); if (setdb.isUserExist(dbuser.User)) { setdb.deleteUser(dbuser.User); ansStr += "用户 " + dbuser.User + "drop成功\r\n"; } bool ans = setdb.createUser(dbuser.User, dbuser.Password, dbuser.Tablespace); if (ans == true) { ansStr += "用户 " + dbuser.User + "创建成功\r\n"; } else { ansStr += "用户 " + dbuser.User + "创建失败\r\n"; } } } ansStr += "结束创建\r\n"; MessageBox.Show(ansStr); } catch (Exception eg) { MessageBox.Show(eg.Message.ToString()); } }