Esempio n. 1
0
        private void svcList_SelectedIndexChanged(object sender, EventArgs e)
        {
            //初始化数据库选项
            meConnectType connType;
            int           rtn    = 0;
            mcEnumIDs     gdbIDs = null;
            int           gdbID  = 0;
            ListViewItem  item   = null;

            if (svcList.SelectedItem != null)
            {
                m_svcObj = new mcGDBServer();

                //1.判断数据源连接类型,若为非本地连接,需要输入用户名和密码
                connType = m_svcMng.Get(svcList.SelectedIndex).SvcType;
                if (connType == meConnectType.meConLocal || connType == meConnectType.meCon6xLocal)
                {
                    rtn = m_svcObj.Connect(m_svcMng.Get(svcList.SelectedIndex).SvcName, "", "");
                }
                //else
                //{
                //    logFrm logInfo = new logFrm();
                //    if (logInfo.ShowDialog() != DialogResult.OK)
                //        return;
                //    rtn = m_svcObj.Connect(m_svcMng.Get(svcList.SelectedIndex).SvcName, logInfo.m_user, logInfo.m_pswd);
                //}

                if (rtn < 1)
                {
                    return;
                }

                //2.获取当前数据源连接包含的所有数据库
                gdbIDs = m_svcObj.gdbs;
                if (gdbIDs == null)
                {
                    return;
                }

                //gdbList.Items.Clear();
                //2.1.取第一条记录
                gdbID = gdbIDs.Reset();
                while (gdbID > 0)
                {
                    m_gdbObj = m_svcObj.get_gdb0(gdbID);
                    this.cbxNewDB.Items.Add(m_gdbObj.name);
                    this.cbsSourceDB.Items.Add(m_gdbObj.name);
                    //2.2取下一条记录
                    gdbID = gdbIDs.Next();
                }
            }
        }
Esempio n. 2
0
        private void btnGeoUpdate_Click(object sender, EventArgs e)
        {
            GeoUpdateParameterSetDlg aupDlg = new GeoUpdateParameterSetDlg(this);

            if (aupDlg.ShowDialog() == DialogResult.OK)
            {
                mcGDBServer  GDBSvr            = null;
                mcGDataBase  GDB               = null;
                mcGDataBase  GDB_source        = null;
                mcQueryDef   QueryDef          = null;
                mcQueryDef   QueryDef_source   = null;
                mcGeoPolygon GeoPolygon        = null;
                mcGeoPolygon GeoPolygon_source = null;
                IGeometry    pgeo              = null;
                IGeometry    pgeo_source       = null;
                IVectorCls   VecCls            = null;
                IVectorCls   VecCls_source     = null;
                mcObjectID   ID         = null;
                mcObjectID   ID_Source  = null;
                IVectorCls   VecCls_Add = null;

                GDBSvr            = new mcGDBServer();
                QueryDef          = new mcQueryDef();
                QueryDef_source   = new mcQueryDef();
                GeoPolygon        = new mcGeoPolygon();
                GeoPolygon_source = new mcGeoPolygon();
                //变量初始化
                ID        = new mcObjectID();
                ID_Source = new mcObjectID();
                //连接数据源,打开数据库
                try
                {
                    GDBSvr.Connect("MapGislocal", "", "");
                    GDB           = GDBSvr.get_gdb(DB);
                    GDB_source    = GDBSvr.get_gdb(DB_source);
                    VecCls        = GDB.get_XClass(meXClsType.meXSFCls) as IVectorCls;
                    VecCls_source = GDB_source.get_XClass(meXClsType.meXSFCls) as IVectorCls;
                    VecCls.Open(KQ, 0);
                    VecCls_source.Open(KQ_source, 0);

                    ID.Int = 1;
                    VecCls.GetGeometry(ID, out pgeo);
                    GeoPolygon = (mcGeoPolygon)pgeo;
                    //空间查询模式。主要有四种 :相交、外包矩形相交、相等、相离,具体意思及区别见技术文档
                    QueryDef.set_Spatial(GeoPolygon, meSpaQueryMode.meModeIntersect);

                    ID_Source.Int = 1;
                    VecCls_source.GetGeometry(ID_Source, out pgeo_source);
                    GeoPolygon_source = (mcGeoPolygon)pgeo_source;
                    //空间查询模式。主要有四种 :相交、外包矩形相交、相等、相离,具体意思及区别见技术文档
                    QueryDef_source.set_Spatial(GeoPolygon_source, meSpaQueryMode.meModeIntersect);
                    string[] keys = new string[dict.Count];
                    dict.Keys.CopyTo(keys, 0);
                    foreach (string key in keys)
                    {
                        if ("".Equals(key))
                        {
                            mcQueryDef  QDef      = null;
                            mcRecordSet RecordSet = null;
                            QueryDef = new mcQueryDef();
                            IVectorCls VecCls_data = null;
                            //打开待分析数据
                            VecCls_data = GDB.get_XClass(meXClsType.meXSFCls) as IVectorCls;
                            VecCls_data.Open(dict[key], 0);
                            VecCls_Add = GDB_source.get_XClass(meXClsType.meXSFCls) as IVectorCls;
                            VecCls_Add.Create(dict[key], meGeomConstrainType.mefReg, 0, 0, null);
                            //设置属性查询条件
                            QueryDef.Filter = "";
                            VecCls_data.Select(QDef, out RecordSet);
                            int rtn = VecCls_Add.CopySet(RecordSet);
                            VecCls_Add.Close();
                            VecCls_data.Close();
                            break;
                        }
                        SpatialDataAutoUpdate(GDBSvr, GDB, GDB_source, QueryDef, QueryDef_source, dict[key], key, Field, Field_source);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    VecCls.Close();
                    VecCls_source.Close();
                    GDBSvr.DisConnect();
                    GDB.Close();
                    GDB_source.Close();
                }
            }
        }