Esempio n. 1
0
        //测试链接信息是否可用
        private bool CanOpenConnect(SysCommon.Gis.SysGisDB vgisDb, string strType, string strServer, string strService, string strDatabase, string strUser, string strPassword, string strVersion)
        {
            bool blnOpen = false;

            Exception Err;

            if (strType.ToUpper() == "ORACLE" || strType.ToUpper() == "SQLSERVER")
            {
                blnOpen = vgisDb.SetWorkspace(strServer, strService, strDatabase, strUser, strPassword, strVersion, out Err);
            }
            else if (strType.ToUpper() == "ACCESS")
            {
                blnOpen = vgisDb.SetWorkspace(strServer, SysCommon.enumWSType.PDB, out Err);
            }
            else if (strType.ToUpper() == "FILE")
            {
                blnOpen = vgisDb.SetWorkspace(strServer, SysCommon.enumWSType.GDB, out Err);
            }

            return(blnOpen);
        }
Esempio n. 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Exception eError = null;

            m_FeaLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer;
            IFeatureSelection pFeaSel = m_FeaLayer as IFeatureSelection;

            if (pFeaSel.SelectionSet == null || pFeaSel.SelectionSet.Count == 0)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请在图上选择范围!");
                return;
            }
            else
            {
                m_Geometry = GetFeaLayerGeometry(pFeaSel, m_FeaLayer);
            }
            if (m_Geometry == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请设置图幅数据范围!");
                return;
            }
            //对范围进行检查看该范围是否是本地工作库图幅数据的总范围……

            //将范围信息解析后写入XML中
            byte[] xmlByte      = xmlSerializer(m_Geometry);
            string base64String = Convert.ToBase64String(xmlByte);

            //XmlDocument DocXml = (m_AppGIS.ProjectTree.SelectedNode.Tag as XmlNode)
            //DocXml.Load(ModData.v_projectXML);
            XmlNode    ProNode   = m_AppGIS.ProjectTree.SelectedNode.Tag as XmlNode;//DocXml.SelectSingleNode(".//工程[@名称='" + m_AppGIS.ProjectTree.SelectedNode.Name + "']");
            XmlElement RangeElem = ProNode.SelectSingleNode(".//内容//图幅工作库//范围信息") as XmlElement;

            RangeElem.SetAttribute("范围", base64String);
            ProNode.OwnerDocument.Save(ModData.v_projectDetalXML);   //cyf 20110628

            //cyf 20110621 modify ;将范围信息存储到系统维护库当中
            #region 获取系统维护库连接信息,并连接系统维护库,将工作空间保存起来
            if (ModData.TempWks == null)
            {
                bool blnCanConnect            = false;
                SysCommon.Gis.SysGisDB vgisDb = new SysCommon.Gis.SysGisDB();
                if (File.Exists(ModData.v_ConfigPath))
                {
                    //获得系统维护库连接信息
                    SysCommon.Authorize.AuthorizeClass.GetConnectInfo(ModData.v_ConfigPath, out ModData.Server, out ModData.Instance, out ModData.Database, out ModData.User, out ModData.Password, out ModData.Version, out ModData.dbType);
                    //连接系统维护库
                    blnCanConnect = ModDBOperator.CanOpenConnect(vgisDb, ModData.dbType, ModData.Server, ModData.Instance, ModData.Database, ModData.User, ModData.Password, ModData.Version);
                }
                else
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "缺失系统维护库连接信息文件:" + ModData.v_ConfigPath + "/n请重新配置");
                    return;
                }
                if (!blnCanConnect)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "系统能够维护库连接失败,请检查!");
                    return;
                }
                ModData.TempWks = vgisDb.WorkSpace;
            }
            if (ModData.TempWks == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取系统维护库工作空间失败,请检查!");
                return;
            }
            #endregion
            ////将范围信息写入数据库
            //if (!File.Exists(ModData.v_DbInterConn)) return;

            ////读取系统维护库连接信息
            //XmlDocument xmlConnDoc = new XmlDocument();
            //xmlConnDoc.Load(ModData.v_DbInterConn);
            //XmlElement ele = xmlConnDoc.SelectSingleNode(".//系统维护库连接信息") as XmlElement;
            //if (ele == null) return;
            //string sConnect = ele.GetAttribute("连接字符串");//系统维护库连接字符串
            ////连接系统维护库
            //SysCommon.DataBase.SysTable pTable = new SysCommon.DataBase.SysTable();
            //pTable.SetDbConnection(sConnect, SysCommon.enumDBConType.ORACLE, SysCommon.enumDBType.ORACLE, out eError);
            //if (eError != null)
            //{
            //    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "提示,连接系统维护库失败!");
            //    return;
            //}
            if (m_AppGIS.ProjectTree.SelectedNode.Name.ToString().Trim() == "")
            {
                return;
            }

            ///原有更新ROW的方法
            //string upStr = "update DATABASEMD set DBPARA='" + base64String + "' where ID=" + Convert.ToInt32(m_AppGIS.ProjectTree.SelectedNode.Name.ToString().Trim());
            //pTable.UpdateTable(upStr, out eError);
            //if (eError != null)
            //{
            //    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "提示,更新图幅范围信息失败!");
            //    return;
            //}

            //现在的更新ROW xisheng changed 20111018
            SysGisTable sysTable = new SysGisTable(ModData.TempWks);
            Dictionary <string, object> dicData = new Dictionary <string, object>();
            dicData.Add("DBPARA", base64String);
            try { sysTable.UpdateRow("DATABASEMD", "ID='" + Convert.ToInt32(m_AppGIS.ProjectTree.SelectedNode.Name.ToString().Trim()) + "'", dicData, out eError); }
            catch
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "提示,更新图幅范围信息失败!+详细信息:" + eError.Message);
                return;
            }

            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "完成范围信息的获取和存储!");
            //end
            this.Close();
        }