Ejemplo n.º 1
0
        /// <summary>
        /// 删除实体数据——填充DataGridView
        /// </summary>
        /// <param name="updateInfo"></param>
        private void FillGridViewDelete(ClsUpdateInfo updateInfo)
        {
            int index = this.updateContent.Rows.Add();

            string   entiField  = ClsConfig.LayerConfigs[(updateInfo.UpdatedLyr.FeatureClass as IDataset).Name].EntityID;
            string   fromField  = ClsConfig.LayerConfigs[(updateInfo.UpdatedLyr.FeatureClass as IDataset).Name].StartVersion;
            string   sourceName = ClsConfig.LayerConfigs[(updateInfo.UpdatedLyr.FeatureClass as IDataset).Name].SourceName;
            string   sourceType = ClsConfig.LayerConfigs[(updateInfo.UpdatedLyr.FeatureClass as IDataset).Name].SourceType;
            IFeature feat       = updateInfo.Feature;

            string entityID = feat.get_Value(feat.Fields.FindField(entiField)).ToString();

            this.updateContent.Rows[index].Cells[0].Value = entityID;

            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.WhereClause = "ENTIID = '" + entityID + "'";
            ICursor cursor = this._entityTable.Search(queryFilter, false);
            IRow    row    = cursor.NextRow();

            string name = row.get_Value(row.Fields.FindField("FNAME")).ToString();

            this.updateContent.Rows[index].Cells[1].Value = name;

            string startTime = row.get_Value(row.Fields.FindField("STARTDATE")).ToString();

            this.updateContent.Rows[index].Cells[2].Value = startTime;

            string   fromTimeID = feat.get_Value(feat.Fields.FindField(fromField)).ToString();
            DateTime fromTime   = this.GetDateTime(fromTimeID, sourceName, this._versionTable);

            this.updateContent.Rows[index].Cells[3].Value = fromTime.ToShortDateString();
            this.updateContent.Rows[index].Cells[4].Value = fromTime.ToShortDateString();

            this.updateContent.Rows[index].Cells[5].Value = sourceName;

            string eSource = row.get_Value(row.Fields.FindField("ESOURCE")).ToString();

            this.updateContent.Rows[index].Cells[6].Value = eSource;

            int    keysCount      = ClsConfig.SourceDatabase.Keys.Count;
            string updateDateBase = "";

            for (int i = 0; i < keysCount; i++)
            {
                string key = ClsConfig.SourceDatabase.Keys.ElementAt(i);
                if (eSource.Contains(key))
                {
                    if (key != sourceType)
                    {
                        updateDateBase += key;
                    }
                }
            }
            this.updateContent.Rows[index].Cells[7].Value = updateDateBase;
            this.updateContent.Rows[index].Tag            = updateInfo;
        }
Ejemplo n.º 2
0
        private void updateContent_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            ClsUpdateInfo updateInfo      = this.updateContent.Rows[e.RowIndex].Tag as ClsUpdateInfo;
            IMapControl4  pMainMapControl = ClsControl.MapControlMain;

            pMainMapControl.Map.ClearSelection();//清除地图的选择
            IEnvelope env = new EnvelopeClass();

            pMainMapControl.Map.SelectFeature(updateInfo.UpdatedLyr, updateInfo.Feature);//将查询到的地物作为选择对象高亮显示在地图上
            env.Union(updateInfo.Feature.Shape.Envelope);
            //env.Expand(2, 2, true);
            //pMainMapControl.Extent = env;

            IPoint pt = new PointClass();

            pt.X = (env.UpperLeft.X + env.LowerRight.X) / 2;
            pt.Y = (env.UpperLeft.Y + env.LowerRight.Y) / 2;
            pMainMapControl.CenterAt(pt);
            pMainMapControl.ActiveView.Refresh();//刷新地图,这样才能显示出地物
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 同步更新地理实体表
        /// </summary>
        /// <param name="updateInfo"></param>
        public void UpdateNewEntiData(ClsUpdateInfo updateInfo)
        {
            string   entiField = ClsConfig.LayerConfigs[(updateInfo.UpdatedLyr.FeatureClass as IDataset).Name].EntityID;
            IFeature feat      = updateInfo.Feature;

            //刷新地理实体表
            IDataset       dataset       = this._entityTable as IDataset;
            IWorkspace     workspace     = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IRowBuffer rowBuffer = null;
            ICursor    rowCursor = null;
            IRow       row       = null;

            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.WhereClause = entiField + " = '" + feat.get_Value(feat.Fields.FindField(entiField)).ToString() + "'";
            //把实体表的遍历放入到Feature的遍历过程中
            rowCursor = this._entityTable.Search(queryFilter, false);
            //test
            int test = this._entityTable.RowCount(null);

            row = rowCursor.NextRow();
            if (row == null)
            {
                rowBuffer = this._entityTable.CreateRowBuffer();
                rowCursor = this._entityTable.Insert(true);
                rowBuffer = InsertEntiData(rowBuffer, feat, this._versionTable, (updateInfo.UpdatedLyr.FeatureClass as IDataset).Name);
                rowCursor.InsertRow(rowBuffer);
            }
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 新增实体数据——填充DataGridView
        /// </summary>
        /// <param name="updateInfo"></param>
        private void FillGridViewAdd(ClsUpdateInfo updateInfo)
        {
            int index = this.updateContent.Rows.Add();

            string   entiField  = ClsConfig.LayerConfigs[(updateInfo.UpdatedLyr.FeatureClass as IDataset).Name].EntityID;
            string   nameField  = ClsConfig.LayerConfigs[(updateInfo.UpdatedLyr.FeatureClass as IDataset).Name].NameField;
            string   fromField  = ClsConfig.LayerConfigs[(updateInfo.UpdatedLyr.FeatureClass as IDataset).Name].StartVersion;
            string   sourceName = ClsConfig.LayerConfigs[(updateInfo.UpdatedLyr.FeatureClass as IDataset).Name].SourceName;
            string   sourceType = ClsConfig.LayerConfigs[(updateInfo.UpdatedLyr.FeatureClass as IDataset).Name].SourceType;
            IFeature feat       = updateInfo.Feature;

            string entityID = feat.get_Value(feat.Fields.FindField(entiField)).ToString();

            this.updateContent.Rows[index].Cells[0].Value = entityID;

            string name = feat.get_Value(feat.Fields.FindField(nameField)).ToString();

            this.updateContent.Rows[index].Cells[1].Value = name;

            string   fromTimeID = feat.get_Value(feat.Fields.FindField(fromField)).ToString();
            DateTime fromTime   = this.GetDateTime(fromTimeID, sourceName, this._versionTable);

            this.updateContent.Rows[index].Cells[2].Value = fromTime.ToShortDateString();

            this.updateContent.Rows[index].Cells[3].Value = "";
            this.updateContent.Rows[index].Cells[4].Value = fromTime.ToShortDateString();
            this.updateContent.Rows[index].Cells[5].Value = sourceName;
            this.updateContent.Rows[index].Cells[6].Value = sourceType;

            int    keysCount      = ClsConfig.SourceDatabase.Keys.Count;
            string updateDateBase = "";

            for (int i = 0; i < keysCount; i++)
            {
                string key = ClsConfig.SourceDatabase.Keys.ElementAt(i);
                if (key != sourceType)
                {
                    updateDateBase += key;
                }
            }
            this.updateContent.Rows[index].Cells[7].Value = updateDateBase;
            this.updateContent.Rows[index].Tag            = updateInfo;


            ////刷新地理实体表
            UpdateNewEntiData(updateInfo);


            ////刷新地理实体表
            //IDataset dataset = this._entityTable as IDataset;
            //IWorkspace workspace = dataset.Workspace;
            //IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;
            //workspaceEdit.StartEditing(true);
            //workspaceEdit.StartEditOperation();

            //IRowBuffer rowBuffer = null;
            //ICursor rowCursor = null;
            //IRow row = null;

            //IQueryFilter queryFilter = new QueryFilterClass();
            //queryFilter.WhereClause = entiField + " = '" + feat.get_Value(feat.Fields.FindField(entiField)).ToString() + "'";
            ////把实体表的遍历放入到Feature的遍历过程中
            //rowCursor = this._entityTable.Search(queryFilter, false);
            //row = rowCursor.NextRow();
            //while (row == null)
            //{
            //    rowBuffer = this._entityTable.CreateRowBuffer();
            //    rowCursor = this._entityTable.Insert(true);
            //    rowBuffer = InsertEntiData(rowBuffer, feat, this._versionTable, pFeatureLayname);
            //    rowCursor.InsertRow(rowBuffer);
            //}
            //workspaceEdit.StopEditOperation();
            //workspaceEdit.StopEditing(true);
        }
Ejemplo n.º 5
0
        private List <ClsUpdateInfo> GetUpdateInfo(IFeatureLayer toUpdateLyr, IFeatureLayer updatedLyr)
        {
            List <ClsUpdateInfo> updateInfos = new List <ClsUpdateInfo>();

            string usourceField     = ClsConfig.LayerConfigs[(updatedLyr.FeatureClass as IDataset).Name].SourceName;
            string fromVersionField = ClsConfig.LayerConfigs[(updatedLyr.FeatureClass as IDataset).Name].StartVersion;
            string toVersionField   = ClsConfig.LayerConfigs[(updatedLyr.FeatureClass as IDataset).Name].EndVersion;
            string guidField        = ClsConfig.LayerConfigs[(updatedLyr.FeatureClass as IDataset).Name].GUID;
            //只查询一个字段
            //获取更新数据的当前版本号
            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.WhereClause = "USOURSE = '" + usourceField + "'";
            ICursor rowCursor      = this._versionTable.Search(queryFilter, false);
            IRow    row            = rowCursor.NextRow();
            int     currentVersion = 0;

            while (row != null)
            {
                string version    = row.get_Value(row.Fields.FindField("VERSION_ID")).ToString();
                int    versionInt = Int32.Parse(version);
                if (versionInt > currentVersion)
                {
                    currentVersion = versionInt;
                }
                row = rowCursor.NextRow();
            }
            //查询两个字段
            //获取更新数据的版本号和当前版本号的关系
            IFeatureCursor pCursor  = null;
            IFeature       pFeature = null;

            queryFilter             = new QueryFilterClass();
            queryFilter.WhereClause = fromVersionField + " = '" + currentVersion.ToString() + "' or " + toVersionField + " = '" + currentVersion.ToString() + "'";
            pCursor = updatedLyr.FeatureClass.Search(queryFilter, false);
            if (pCursor != null)
            {
                pFeature = pCursor.NextFeature();
            }

            ClsBarSync pBarEntiUpdate = new ClsBarSync(progressBarXEntiUpdate);

            pBarEntiUpdate.SetMax(updatedLyr.FeatureClass.FeatureCount(queryFilter));

            //两个while循环遍历两个图层中的每一个要素
            while (pFeature != null)
            {
                string startVersion = pFeature.get_Value(pFeature.Fields.FindField(fromVersionField)).ToString();
                string endVersion   = pFeature.get_Value(pFeature.Fields.FindField(toVersionField)).ToString();
                string guid         = pFeature.get_Value(pFeature.Fields.FindField(guidField)).ToString();
                //起始号为当前版本,终止号为99999的话就是新增的要素
                if (startVersion == currentVersion.ToString() && endVersion == "99999")
                {
                    ClsUpdateInfo ui = new ClsUpdateInfo();
                    ui.UpdateState = "New";
                    ui.GUID        = guid;
                    ui.Feature     = pFeature;
                    ui.ToUpdateLyr = toUpdateLyr;
                    ui.UpdatedLyr  = updatedLyr;
                    updateInfos.Add(ui);
                }
                //起始号不同,终止号为当前版本,则为删除
                else if (startVersion != currentVersion.ToString() && endVersion == currentVersion.ToString())
                {
                    ClsUpdateInfo ui = new ClsUpdateInfo();
                    ui.UpdateState = "Delete";
                    ui.GUID        = guid;
                    ui.Feature     = pFeature;
                    ui.ToUpdateLyr = toUpdateLyr;
                    ui.UpdatedLyr  = updatedLyr;
                    updateInfos.Add(ui);
                }
                else
                {
                }

                pBarEntiUpdate.PerformOneStep();
                pFeature = pCursor.NextFeature();
            }

            return(updateInfos);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 遍历更新图层和待更新图层-获取更新信息-guid对比,未使用
        /// </summary>
        /// <param name="toUpdateLyr">原始图层</param>
        /// <param name="updatedLyr">待更新图层</param>
        /// <returns></returns>
        private List <ClsUpdateInfo> GetUpdateInfoDisposed(IFeatureLayer toUpdateLyr, IFeatureLayer updatedLyr)
        {
            string guidFieldTo = ClsConfig.LayerConfigs[(toUpdateLyr.FeatureClass as IDataset).Name].GUID;
            string fromFieldTo = ClsConfig.LayerConfigs[(toUpdateLyr.FeatureClass as IDataset).Name].StartVersion;
            string endFieldTo  = ClsConfig.LayerConfigs[(toUpdateLyr.FeatureClass as IDataset).Name].EndVersion;

            string guidFieldEd = ClsConfig.LayerConfigs[(updatedLyr.FeatureClass as IDataset).Name].GUID;
            string fromFieldEd = ClsConfig.LayerConfigs[(updatedLyr.FeatureClass as IDataset).Name].StartVersion;
            string endFieldEd  = ClsConfig.LayerConfigs[(updatedLyr.FeatureClass as IDataset).Name].EndVersion;

            List <ClsUpdateInfo> updateInfos = new List <ClsUpdateInfo>();

            IFeatureCursor pCursor  = null;
            IFeature       pFeature = null;

            pCursor = updatedLyr.FeatureClass.Search(null, false);
            if (pCursor != null)
            {
                pFeature = pCursor.NextFeature();
            }

            ClsBarSync pBarEntiUpdate = new ClsBarSync(progressBarXEntiUpdate);

            pBarEntiUpdate.SetMax(1);
            pBarEntiUpdate.SetMax(updatedLyr.FeatureClass.FeatureCount(null));

            //两个while循环遍历两个图层中的每一个要素
            while (pFeature != null)
            {
                string guid         = pFeature.get_Value(pFeature.Fields.FindField(guidFieldEd)).ToString();
                string startVersion = pFeature.get_Value(pFeature.Fields.FindField(fromFieldEd)).ToString();
                string endVersion   = pFeature.get_Value(pFeature.Fields.FindField(endFieldEd)).ToString();

                IFeatureCursor pCursorToUpdate  = null;
                IFeature       pFeatureToUpdate = null;
                //查询两个字段
                IQueryFilter queryFilter = new QueryFilterClass();
                queryFilter.WhereClause = guidFieldTo + " = '" + guid + "'";
                pCursorToUpdate         = toUpdateLyr.FeatureClass.Search(queryFilter, false);
                if (pCursorToUpdate != null)
                {
                    pFeatureToUpdate = pCursorToUpdate.NextFeature();
                }
                if (pFeatureToUpdate == null)//没找到GUID相同的,说明是新增的
                {
                    ClsUpdateInfo ui = new ClsUpdateInfo();
                    ui.UpdateState = "New";
                    ui.GUID        = guid;
                    ui.Feature     = pFeature;
                    ui.ToUpdateLyr = toUpdateLyr;
                    ui.UpdatedLyr  = updatedLyr;
                    updateInfos.Add(ui);
                }
                while (pFeatureToUpdate != null)
                {
                    string startVersionToUpdate = pFeatureToUpdate.get_Value(pFeatureToUpdate.Fields.FindField(fromFieldTo)).ToString();
                    string endVersionToUpdate   = pFeatureToUpdate.get_Value(pFeatureToUpdate.Fields.FindField(endFieldTo)).ToString();

                    if (startVersionToUpdate == startVersion && endVersionToUpdate == endVersion)//版本号没变
                    {
                        break;
                    }
                    else
                    {
                        if (startVersionToUpdate == startVersion)//起始号相同,终止号不同,说明要素被删除了
                        {
                            ClsUpdateInfo ui = new ClsUpdateInfo();
                            ui.UpdateState = "Delete";
                            ui.GUID        = guid;
                            ui.Feature     = pFeature;
                            ui.ToUpdateLyr = toUpdateLyr;
                            ui.UpdatedLyr  = updatedLyr;
                            updateInfos.Add(ui);
                            break;
                        }
                        else if (endVersionToUpdate == endVersion)//起始号不同,终止号相同,说明要素被更新了,因为更新的要素才可能出现guid相同,起始号不同
                        {
                            ClsUpdateInfo ui = new ClsUpdateInfo();
                            ui.UpdateState = "Update";
                            ui.GUID        = guid;
                            ui.Feature     = pFeature;
                            ui.ToUpdateLyr = toUpdateLyr;
                            ui.UpdatedLyr  = updatedLyr;
                            updateInfos.Add(ui);
                            break;
                        }
                        else
                        {
                            pFeatureToUpdate = pCursorToUpdate.NextFeature();
                        }
                    }
                }
                pBarEntiUpdate.PerformOneStep();
                pFeature = pCursor.NextFeature();
            }

            return(updateInfos);
        }