示例#1
0
        /// <summary>
        /// cyf 20110602 add:刷新主界面(包括树图以及子数据库的ComBox以及xml界面信息)
        /// </summary>
        /// <param name="ex">错误信息</param>
        /// <returns>bool,成功返回True,错误返回False</returns>
        public bool refurbish(out Exception ex)
        {
            ex = null;
            clsRefurbishDBinfo op = new clsRefurbishDBinfo();

            DevComponents.AdvTree.Node ProjectNode = null;
            op.RefurbishDBinfo(-1, out ProjectNode, out ex);
            /////////连接成功将元信息库的连接信息挂接在树根节点的tag属性上///////
            if (ex != null)
            {
                return(false);
            }
            else
            {
                DevComponents.AdvTree.Node RootNode = null;
                try
                {
                    RootNode     = ModuleData.v_AppDBIntegra.ProjectTree.Nodes[0];
                    RootNode.Tag = ModuleData.TempWks;
                } catch
                {
                    RootNode.Tag = string.Empty;
                }
                return(true);
            }
        }
示例#2
0
        /// <summary>
        /// 刷新主界面(包括树图以及子数据库的ComBox以及xml界面信息)
        /// </summary>
        /// <param name="sConnetInfo">连接字符串</param>
        /// <param name="ex">错误信息</param>
        /// <returns>bool,成功返回True,错误返回False</returns>
        public bool refurbish(string sConnetInfo, out Exception ex)
        {
            ex = null;
            clsRefurbishDBinfo op = new clsRefurbishDBinfo(SysCommon.enumDBConType.ORACLE, SysCommon.enumDBType.ORACLE, sConnetInfo);

            DevComponents.AdvTree.Node ProjectNode = null;
            op.RefurbishDBinfo(-1, out ProjectNode, out ex);
            /////////连接成功将元信息库的连接信息挂接在树根节点的tag属性上///////
            if (ex != null)
            {
                return(false);
            }
            else
            {
                DevComponents.AdvTree.Node RootNode = null;
                try
                {
                    RootNode     = ModuleData.v_AppDBIntegra.ProjectTree.Nodes[0];
                    RootNode.Tag = sConnetInfo;
                }
                catch
                {
                    RootNode.Tag = string.Empty;
                }
                return(true);
            }
        }
示例#3
0
        //执行库体创建
        private void btn_OK_Click(object sender, EventArgs e)
        {
            #region 界面参数输入完整性控制
            //cf 20110628 modify:
            if (sDBFormatID != enumInterDBFormat.FTP.GetHashCode().ToString())
            {
                if (string.IsNullOrEmpty(textRuleFilePath.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "库体配置文件不能为空!"); return;
                }
            }

            if (sDBFormatID == enumInterDBFormat.ARCGISPDB.GetHashCode().ToString() || sDBFormatID == enumInterDBFormat.ARCGISGDB.GetHashCode().ToString())
            {
                if (string.IsNullOrEmpty(this.txtDataBase.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "数据库路径不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtProjFilePath.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "空间参考文件不能为空!"); return;
                }
            }
            else if (sDBFormatID == enumInterDBFormat.ARCGISSDE.GetHashCode().ToString())
            {
                if (string.IsNullOrEmpty(this.txtServer.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "服务器不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtUser.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "用户不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtPassWord.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "密码不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtProjFilePath.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "空间参考文件不能为空!"); return;
                }
            }
            else if (sDBFormatID == enumInterDBFormat.GEOSTARACCESS.GetHashCode().ToString())
            {
                if (string.IsNullOrEmpty(this.txtDataBase.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "数据库路径不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtProjFilePath.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "空间参考文件不能为空!"); return;
                }
            }
            else if (sDBFormatID == enumInterDBFormat.GEOSTARORACLE.GetHashCode().ToString())
            {
                if (string.IsNullOrEmpty(this.txtProjFilePath.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "空间参考文件不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtDataBase.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "数据不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtUser.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "用户不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtPassWord.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "密码不能为空!"); return;
                }
            }
            else if (sDBFormatID == enumInterDBFormat.GEOSTARORSQLSERVER.GetHashCode().ToString())
            {
                if (string.IsNullOrEmpty(this.txtProjFilePath.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "空间参考文件不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtServer.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "服务器不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtDataBase.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "数据不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtUser.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "用户不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtPassWord.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "密码不能为空!"); return;
                }
            }
            else if (sDBFormatID == enumInterDBFormat.ORACLESPATIAL.GetHashCode().ToString())
            {
                if (string.IsNullOrEmpty(this.txtServer.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "服务器不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtUser.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "用户不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtPassWord.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "密码不能为空!"); return;
                }
            }
            else if (sDBFormatID == enumInterDBFormat.FTP.GetHashCode().ToString())
            {
                if (string.IsNullOrEmpty(this.txtServer.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "服务器不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtUser.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "用户不能为空!"); return;
                }
                if (string.IsNullOrEmpty(this.txtPassWord.Text))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "密码不能为空!"); return;
                }
            }
            //end
            #endregion
            ///////开始库体创建//////
            //string sDBFeaClsName = string.Empty;/////当前要素集名称 cyf 20110707 modify
            List <string> sDBClsNameLst = new List <string>();//cyf 20110707 add:数据集名称

            Exception ex = null;
            //cyf 20110622 modify:
            //int iScale = -1;
            string iScale = "";  //当前数据集比例尺信息
            //end

            string pAllScale  = ""; //所有数据集比例尺信息,比例尺之间以“,”隔开
            string pAllDTName = ""; //所有数据集名称信息,名称之间以“,”隔开

            this.btn_OK.Enabled     = false;
            this.btn_cancle.Enabled = false;
            string sMetaConnect = string.Empty;/////成果文件库元信息库连接字符串
            //*****************************************************
            //guozheng  写日志
            List <string> Pra = new List <string>();
            Pra.Add(sDBName);
            Pra.Add(sDBType);
            Pra.Add(sDBFormat);
            Pra.Add(this.connectInfo);
            Pra.Add(this.txtProjFilePath.Text);
            Pra.Add(this.textRuleFilePath.Text);
            if (ModuleData.v_SysLog != null)
            {
                ModuleData.v_SysLog.Write("创建库体", Pra, DateTime.Now);
            }
            //*****************************************************
            //////////////开始创建库体//////////////////////
            if (sDBTypeID == enumInterDBType.框架要素数据库.GetHashCode().ToString())//////框架要素库  cyf 20110628
            {
                #region 框架要素库创建
                clsDBAdd DBCreater = new clsDBAdd();
                DBCreater.ProcBar      = this.progressBar1;
                DBCreater.DataBaseOper = this.m_DBOper;
                //cyf 20110623 delete  cyf 20110707 modify
                DBCreater.DBCreate(sDBFormatID, sDBTypeID, this.txtServer.Text, this.txtservername.Text, this.txtDataBase.Text, txtUser.Text, txtPassWord.Text, this.txtVersion.Text, txtProjFilePath.Text, textRuleFilePath.Text, out iScale, out sDBClsNameLst, out ex);
                if (ex != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", ex.Message);
                    this.btn_OK.Enabled     = true;
                    this.btn_cancle.Enabled = true;
                    return;
                }
                //end
                this.btn_cancle.Enabled = true;
                #endregion

                //框架要素库创建完毕后,更新系统维护库信息
                DBCreater.UpdateDB(m_CurProNode, iScale, sDBClsNameLst, out pAllScale, out pAllDTName, out ex); //cyf 20110707 modify
            }
            else if (sDBTypeID == enumInterDBType.成果文件数据库.GetHashCode().ToString())                             /////////成果文件库  cyf 20110628
            {
                #region 成果文件库创建
                try
                {
                    sMetaConnect = "Data Source=" + this.txtServer.Text.Trim() + ";User ID=" + this.txtUser.Text.Trim() + ";Password="******"获取元信息库连接信息失败");
                }

                if (ex != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "库体初始化失败!\n原因:" + ex.Message);
                    this.btn_OK.Enabled     = true;
                    this.btn_cancle.Enabled = true;
                    return;
                }
                #endregion
                //更新系统维护库
                string sConnectInfo = m_sDBConnectStr + "|Data Source=" + this.txtServer.Text.Trim() + ";User ID=" + this.txtUser.Text.Trim() + ";Password="******"提示", "数据库创建已成功,但界面信息刷新失败!\n原因:" + ex.Message);
                this.btn_OK.Enabled     = true;
                this.btn_cancle.Enabled = true;
                return;
            }
            else
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库初始化成功!");
            }
            this.Close();


            //end
            #region 原有代码

            ////////////创建成功将更新系统维护库信息、刷新界面挂接信息////////

            /*
             * string sConnectInfo = string.Empty;
             * if (m_DBType == enumInterDBType.框架要素数据库)//////框架要素库在连接信息后增加要素集名称
             * {
             *     sConnectInfo = this.txtServer.Text + "|" + this.txtservername.Text + "|" + this.txtDataBase.Text + "|" + this.txtUser.Text + "|" + this.txtPassWord.Text + "|" + this.txtVersion.Text + "|" + sDBFeaClsName;
             * }
             * else if (m_DBType == enumInterDBType.成果文件数据库)////成果文件库在连接信息后增加元信息库连接字符串
             * {
             *     sConnectInfo = m_sDBConnectStr + "|Data Source=" + this.txtServer.Text.Trim() + ";User ID=" + this.txtUser.Text.Trim() + ";Password="******"|" + this.txtservername.Text + "|" + this.txtDataBase.Text + "|" + this.txtUser.Text + "|" + this.txtPassWord.Text + "|" + this.txtVersion.Text;
             * }
             * //cyf 20110603 modify:修改系统维护库读取方式
             * long lStateID = -1;
             * IFeatureWorkspace pFeaWS = ModuleData.TempWks as IFeatureWorkspace;
             * IQueryDef pQueryDes = pFeaWS.CreateQueryDef();
             * pQueryDes.Tables = "DATABASESTATEMD";
             * pQueryDes.SubFields = "ID";
             * pQueryDes.WhereClause = "DATABASESTATE='库体已初始化'";
             * try
             * {
             *     //查询表格
             *     ICursor pCursor = pQueryDes.Evaluate();
             *     if (pCursor == null)
             *     {
             *         SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库状态修改错误");
             *         this.btn_OK.Enabled = true;
             *         this.btn_cancle.Enabled = true;
             *         return;
             *     }
             *     IRow pRow = pCursor.NextRow();
             *     if (pRow != null)
             *     {
             *         lStateID = Convert.ToInt64(pRow.get_Value(0));
             *     }
             *     //释放游标
             *     System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
             * } catch { lStateID = -1; }
             * if (lStateID == -1)
             * {
             *     SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库状态修改错误");
             *     this.btn_OK.Enabled = true;
             *     this.btn_cancle.Enabled = true;
             *     return;
             * }
             * try///////更新数据库连接信息以及数据库状态ID
             * {
             *     string sql = "UPDATE DATABASEMD SET CONNECTIONINFO='" + sConnectInfo + "',DATABASSTATEID=" + lStateID.ToString() + ",SCALE=" + iScale+ " WHERE ID=" + lDBid.ToString();
             *     ModuleData.TempWks.ExecuteSQL(sql);
             *     if (ex != null)
             *     {
             *         SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库连接信息更新失败");
             *         this.btn_OK.Enabled = true;
             *         this.btn_cancle.Enabled = true;
             *         return;
             *     }
             * } catch (Exception eError)
             * {
             *     //****************************************************
             *     if (ModuleData.v_SysLog != null)
             *         ModuleData.v_SysLog.Write(eError, null, DateTime.Now);
             *     //****************************************************
             *     SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库连接信息更新失败");
             *     this.btn_OK.Enabled = true;
             *     this.btn_cancle.Enabled = true;
             *     return;
             * }
             */

            //long lStateID = -1;
            //string sql = "SELECT ID  FROM DATABASESTATEMD WHERE DATABASESTATE='库体已初始化'";
            //try
            //{
            //    DataTable gettable = this.m_DBOper.GetSQLTable(sql, out ex);
            //    lStateID = Convert.ToInt64(gettable.Rows[0][0].ToString());
            //}
            //catch { lStateID = -1; }
            //if (lStateID == -1)
            //{
            //    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库状态修改错误");
            //    this.btn_OK.Enabled = true;
            //    this.btn_cancle.Enabled = true;
            //    return;
            //}
            //try///////更新数据库连接信息以及数据库状态ID
            //{
            //    sql = "UPDATE DATABASEMD SET CONNECTIONINFO='" + sConnectInfo + "',DATABASSTATEID=" + lStateID.ToString() + ",SCALE=" + iScale.ToString() + " WHERE ID=" + lDBid.ToString();
            //    this.m_DBOper.UpdateTable(sql, out ex);
            //    if (ex != null)
            //    {
            //        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库连接信息更新失败");
            //        this.btn_OK.Enabled = true;
            //        this.btn_cancle.Enabled = true;
            //        return;
            //    }
            //}
            //catch (Exception eError)
            //{
            //    //****************************************************
            //    if (ModuleData.v_SysLog != null)
            //        ModuleData.v_SysLog.Write(eError, null, DateTime.Now);
            //    //****************************************************
            //    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库连接信息更新失败");
            //    this.btn_OK.Enabled = true;
            //    this.btn_cancle.Enabled = true;
            //    return;
            //}
            //////////////刷新界面////////////////////////
            //clsRefurbishDBinfo ReOper = new clsRefurbishDBinfo();
            //ReOper.DBOper = this.m_DBOper;
            //DevComponents.AdvTree.Node projectNode = null;
            //ReOper.RefurbishDBinfo(lDBid, out projectNode, out ex);
            //if (ex != null)
            //{
            //    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库创建已成功,但界面信息刷新失败!\n原因:" + ex.Message);
            //    this.btn_OK.Enabled = true;
            //    this.btn_cancle.Enabled = true;
            //    return;
            //}
            //else
            //{
            //    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库初始化成功!");
            //}
            //this.Close();
            #endregion
        }