示例#1
0
        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("企业空间库操作结束");
        }
示例#2
0
        private void btnCreateTablespace_Click(object sender, EventArgs e)
        {
            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);
                        bool   ans    = setdb.createTabelspace(dbuser.Tablespace, db.Datafolder + "\\" + dbuser.Tablespace + ".DBF", "50m");
                        if (ans == true)
                        {
                            ansStr += "表空间 " + dbuser.Tablespace + "创建成功\r\n";
                        }
                        else
                        {
                            ansStr += "表空间" + dbuser.Tablespace + "创建失败\r\n";
                        }
                    }

                    else if (ctl is gdbChoose && ((gdbChoose)ctl).Check == true)
                    {
                        string    Name      = ((gdbChoose)ctl).Name;
                        DbSdeUser dbsdeuser = db.DbSdeUserList.Find((DbSdeUser ds) => ds.Name == Name);
                        bool      ans       = setdb.createTabelspace(dbsdeuser.Tablespace, db.Datafolder + "\\" + dbsdeuser.Tablespace + ".DBF", "50m");
                        if (ans == true)
                        {
                            ansStr += "表空间" + dbsdeuser.Tablespace + "创建成功\r\n";
                        }
                        else
                        {
                            ansStr += "表空间" + dbsdeuser.Tablespace + "创建失败\r\n";
                        }
                    }
                }
                ansStr += "结束创建\r\n";
                MessageBox.Show(ansStr);
            }
            catch (Exception eg)
            {
                MessageBox.Show(eg.Message.ToString());
            }
        }
示例#3
0
        private void btnInitSde_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("初始化空间库,会删除空间库原有内容,\r\n,请先备空间库库!\r\n继续请点击确定,放弃请点击取消。", "初始化空间库", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
            {
                return;
            }

            if (!checkSDEimportSet())
            {
                return;
            }
            //初始化 esri授权
            setArcgis.init();
            setArcgis.grant();

            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);


                        string ans1 = "";
                        if (setdb.isUserExist(dbsdeuser.User))
                        {
                            setdb.grantUser(dbsdeuser.User);
                            ans1 += "用户 " + dbsdeuser.User + "授权成功\r\n";
                        }
                        ans1 += engine.importGDB2SDEWithWorkspace(db.Ip, "sde:oracle10g:" + db.Datasource, dbsdeuser.User, dbsdeuser.Password, dbsdeuser.Gdbfile, db.CS_TYPE, db.WKID, db.Prjpath);
                        MessageBox.Show(dbsdeuser.Label + "创建结果如下:\r\n" + ans1);
                    }
                }
            }
            catch (Exception eg)
            {
                MessageBox.Show(eg.Message.ToString());
            }

            MessageBox.Show("企业空间库初始化完成");
        }
示例#4
0
        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());
            }
        }
示例#5
0
        private void saveInstallConfigToConfigXML()
        {
            // 设置修改 绝对路径的保存设置。
            string dataFolder = "";

            try
            {
                setDB db = new setDB("system", startconfig.DB_Password, startconfig.DB_Datasource);
                dataFolder = db.getDataFolder();
            }
            catch (Exception eg)
            {
                MessageBox.Show("链接不上数据库,请检查参数和配置!", "错误");
            }

            set.setInstallSet(startconfig.APP_IP, startconfig.MainFolder, startconfig.DB_IP, startconfig.DB_Datasource, startconfig.DB_Password, dataFolder);
            saveConfigXML();
            laodConfigXML();
        }
示例#6
0
 private void checkDefault_CheckedChanged(object sender, EventArgs e)
 {
     if (this.checkDefault.Checked == true)
     {
         try
         {
             setDB db = new setDB(dbsystemuserset.User, dbsystemuserset.Password, this.datasource.Text);
             this.datafolder.Text = db.getDataFolder();
         }
         catch (Exception eg)
         {
             setMessage.MessageShow("", "链接不上数据库,请检查参数和配置!", this.checkDefault);
             this.checkDefault.Checked = false;
             return;
         }
     }
     else
     {
         this.datafolder.Text = "";
     }
 }
        public void setTables()
        {
            setDB         setdb     = new setDB(dbuser.User, dbuser.Password, datasource);
            List <string> tableList = setdb.getTableListByUser(dbuser.User);

            this.treeView1.Nodes.Clear();
            TreeNode toptn = new TreeNode("数据表");

            treeView1.Nodes.Add(toptn);

            if (tableList != null)
            {
                foreach (string tablename in tableList)
                {
                    TreeNode tn = new TreeNode(tablename);
                    toptn.Nodes.Add(tn);
                }
            }

            treeView1.ExpandAll();
        }