public void DeleteTask(string taskName) { IFeatureWorkspace ws = Util.ServerWorkspace as IFeatureWorkspace; ITable task_tbl = ws.OpenTable("TaskLog"); IQueryFilter filter = new QueryFilterClass(); filter.WhereClause = "TaskName = '" + taskName + "'"; ICursor cur = task_tbl.Search(filter, false); IRow rw = cur.NextRow(); IWorkspaceEdit wse = ws as IWorkspaceEdit; if (rw != null) { string status = rw.get_Value(task_tbl.FindField("Status")) as string; if (status == TaskManager.CHECKOUT_STATUS) { wse.StartEditing(true); rw.Delete(); wse.StopEditing(true); } else if (status == TaskManager.CHECKIN_STATUS) { IVersionedWorkspace vw = ws as IVersionedWorkspace; IVersion ver = vw.FindVersion(taskName); ver.Delete(); wse.StartEditing(true); rw.Delete(); wse.StopEditing(true); } wse.StartEditing(false); ITable tgl_tbl = ws.OpenTable("TaskGridLog"); IQueryFilter tgl_filter = new QueryFilterClass(); tgl_filter.WhereClause = "TaskName = '" + taskName + "'"; tgl_tbl.DeleteSearchedRows(tgl_filter); wse.StopEditing(true); IQueryFilter checkItem_filter = new QueryFilterClass(); checkItem_filter.WhereClause = "VersionName = '" + taskName + "'"; wse.StartEditing(false); ITable checkItemPtn_fc = ws.OpenTable("CheckItemPtn"); checkItemPtn_fc.DeleteSearchedRows(checkItem_filter); ITable checkItemLn_fc = ws.OpenTable("CheckItemLn"); checkItemLn_fc.DeleteSearchedRows(checkItem_filter); ITable checkItemPoly_fc = ws.OpenTable("CheckItemPoly"); checkItemPoly_fc.DeleteSearchedRows(checkItem_filter); wse.StopEditing(true); } }
public static void DeleteCodeDoaminMap(string string_0, string string_1) { if (m_pDomainMapTable == null) { m_pDomainMapTable = AppConfigInfo.OpenTable(CodeDomainMapTableStruct.TableName); if (m_pDomainMapTable == null) { return; } } string[] strArray = string_0.Split(new char[] { '.' }); string_0 = strArray[strArray.Length - 1]; string str = string.Format("{0}='{1}' and {2}='{3}'", new object[] { CodeDomainMapTableStruct.FieldName, string_1, CodeDomainMapTableStruct.FeatureClassName, string_0 }); IQueryFilter queryFilter = new QueryFilter { WhereClause = str }; ICursor o = m_pDomainMapTable.Search(queryFilter, false); IRow row = o.NextRow(); if (row != null) { row.Delete(); } ComReleaser.ReleaseCOMObject(o); }
public void Delete(BaseModel BaseModel) { IRow _row = ((IFeatureWorkspace)_workspace).OpenTable(BaseModel.EntityName).GetRow(((GISModel)BaseModel).ObjectId); _row.Delete(); foreach (ModelProperty _property in BaseModel.ModelProperties.Where(x => !(x.Attribute is EntityShapeFieldAttribute))) { _property.Property.SetValue(BaseModel, null, null); } }
/// <summary> /// 对表MatchedPolygonFCSettingDif进行判断处理 /// </summary> /// <param name="workspace"></param> /// <param name="table"></param> /// <param name="featureWorkspace"></param> /// <returns></returns> private ITable TableExist(IWorkspace2 workspace, ITable table, IFeatureWorkspace featureWorkspace) { IFields fields; //匹配参数表是否存在,存在则打开表并删除相关记录 if (workspace.get_NameExists(esriDatasetType.esriDTTable, ClsConstant.polygonSettingTable)) { table = featureWorkspace.OpenTable(ClsConstant.polygonSettingTable); IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; workspaceEdit.StartEditing(true); workspaceEdit.StartEditOperation(); ICursor cursor = table.Search(null, false); IRow r = cursor.NextRow(); while (r != null) { r.Delete(); r = cursor.NextRow(); } workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); //ClsDeleteTables.DeleteFeatureClass(gdbPath, ClsConstant.lineSettingTable); //fields = CreateMatchedPolylineFCSettingFields(workspace); //UID uid = new UIDClass(); //uid.Value = "esriGeoDatabase.Object"; //IFieldChecker fieldChecker = new FieldCheckerClass(); //IEnumFieldError enumFieldError = null; //IFields validatedFields = null; //fieldChecker.ValidateWorkspace = (IWorkspace)workspace; //fieldChecker.Validate(fields, out enumFieldError, out validatedFields); //table = featureWorkspace.CreateTable(ClsConstant.lineSettingTable, validatedFields, uid, null, ""); } //匹配参数表是否存在,不存在则创建表 else { //返回MatchedPolygonFCSettingDif的所有字段集 fields = CreateMatchedPolygonFCSettingFields(workspace); UID uid = new UIDClass(); uid.Value = "esriGeoDatabase.Object"; IFieldChecker fieldChecker = new FieldCheckerClass(); IEnumFieldError enumFieldError = null; IFields validatedFields = null; fieldChecker.ValidateWorkspace = (IWorkspace)workspace; fieldChecker.Validate(fields, out enumFieldError, out validatedFields); //创建表MatchedPolygonFCSettingDif table = featureWorkspace.CreateTable(ClsConstant.polygonSettingTable, validatedFields, uid, null, ""); } return(table); }
private void toolDelSelect_Click(object sender, EventArgs e) { if (((MessageBox.Show("确定要删除吗", "警告", MessageBoxButtons.YesNo)) == DialogResult.Yes)) { ILayer pLayer = (ILayer)m_mapControl.CustomProperty; IFeatureLayer pFLayer = pLayer as IFeatureLayer; ITable pTable = pFLayer as ITable; IRow pRow = pTable.GetRow(dataGridView1.CurrentCell.RowIndex); pRow.Delete(); TableShow(); MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK); _MapControl.ActiveView.Refresh(); } }
public bool DeleteTemplate(string templateName) { try { IObjectTemplate objectTemplate = _templates.FirstOrDefault(c => c.Name == templateName); if (objectTemplate == null || objectTemplate.ID <= 0) { return(true); } if (_workspace == null) { Connect(); } ITable pTable = _workspace.OpenTable("YT_TEMPLATE_FEATURECLASS"); IWorkspaceEdit pWksEdit = _workspace as IWorkspaceEdit; pWksEdit.StartEditing(true); pWksEdit.StartEditOperation(); IRow pRow = pTable.GetRow(objectTemplate.ID); if (pRow != null) { pRow.Delete(); } //pTable = _workspace.OpenTable("YT_TEMPLATE_FIELD"); //foreach (IYTField ytField in objectTemplate.Fields) //{ // if (ytField.ID > 0) // { // pRow = pTable.GetRow(ytField.ID); // if(pRow != null) pRow.Delete(); // } //} pWksEdit.StopEditOperation(); pWksEdit.StopEditing(true); DisConnect(); return(true); } catch (Exception ex) { MessageService.Current.Warn("系统发生错误:" + ex.Message); return(false); throw; } }
private void 除选中ToolStripMenuItem_Click(object sender, EventArgs e) { if (((MessageBox.Show("确定要删除吗", "警告", MessageBoxButtons.YesNo)) == DialogResult.Yes)) { ITable pTable = pFLayer as ITable; IRow pRow = pTable.GetRow(row_index); pRow.Delete(); MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK); _MapControl.ActiveView.Refresh(); pFCuror = pFClass.Search(null, false); RefreshDataGridViewDataSource(gdvAttribute, GetAttributeTable(pFClass, pFCuror)); } }
//删除选中的要素 private void button4_Click(object sender, EventArgs e) { row_index = dataGridView1.CurrentRow.Index; if (((MessageBox.Show("确定要删除吗", "警告", MessageBoxButtons.YesNo)) == DialogResult.Yes)) { ILayer pLayer = currentLayer; IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer; ITable pTable = pFeatureLayer as ITable; IRow pRow = pTable.GetRow(row_index); pRow.Delete(); TableShow(); MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK); _MapControl.ActiveView.Refresh(); RefreshTable refresh = new RefreshTable(); refresh.Refresh(dataGridView1, pFeatureLayer); } }
private void toolDelSelect_Click(object sender, EventArgs e) { if (((MessageBox.Show("确定要删除吗", "警告", MessageBoxButtons.YesNo)) == DialogResult.Yes)) { ILayer pLayer = (ILayer)m_mapControl.CustomProperty; IFeatureLayer pFLayer = pLayer as IFeatureLayer; ITable pTable = pFLayer as ITable; int val = this.gridView1.GetFocusedDataSourceRowIndex(); DataRowView row = (DataRowView)this.gridView1.GetRow(val); int oid = int.Parse(row[pFLayer.FeatureClass.OIDFieldName].ToString()); IRow pRow = pTable.GetRow(oid); pRow.Delete(); TableShow(); MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK); _MapControl.ActiveView.Refresh(); } }
private void btnDeleteAssignUser_Click(object sender, EventArgs e) { ITable table = CommonClass.OpenTable("JLK_STAFFRoles"); string str = string.Concat("RoleID = ", this.lvRoles.SelectedItems[0].Tag.ToString(), " and staffid = '"); IQueryFilter queryFilterClass = new QueryFilterClass(); for (int i = this.lvStaffRole.SelectedItems.Count - 1; i >= 0; i--) { ListViewItem item = this.lvStaffRole.SelectedItems[i]; queryFilterClass.WhereClause = string.Concat(str, item.SubItems[1].Text, "'"); ICursor cursor = table.Search(queryFilterClass, false); for (IRow j = cursor.NextRow(); j != null; j = cursor.NextRow()) { j.Delete(); } Marshal.ReleaseComObject(cursor); cursor = null; this.lvStaffRole.Items.Remove(item); } }
private void deleteButton_Click(object sender, EventArgs e) { if (((MessageBox.Show("确定要删除吗", "警告", MessageBoxButtons.YesNo)) == DialogResult.Yes)) { //ILayer pLayer = (ILayer)m_mapControl.CustomProperty; IFeatureLayer pFLayer = m_Layer as IFeatureLayer; ITable pTable = pFLayer as ITable; int row_num = dataGridView.SelectedRows.Count; for (int i = 0; i < row_num; i++) { int row_index = dataGridView.SelectedRows[i].Index; IRow pRow = pTable.GetRow(row_index); pRow.Delete(); } this.CreateAttributeTable(m_Layer); MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK); mapControl.ActiveView.Refresh(); } }
private void m_pDataTable_RowDeleted(object sender, DataRowChangeEventArgs e) { if (this.m_InEditing && this.m_CanDo) { try { object[] itemArray = e.Row.ItemArray; IWorkspaceEdit workspace = (this.m_pTable as IDataset).Workspace as IWorkspaceEdit; if (!(itemArray[0] is DBNull)) { int num = Convert.ToInt32(itemArray[0]); IQueryFilter queryFilter = new QueryFilterClass { WhereClause = this.m_pTable.OIDFieldName + " = " + num.ToString() }; ICursor o = this.m_pTable.Search(queryFilter, false); IRow row = o.NextRow(); if (row != null) { workspace.StartEditOperation(); row.Delete(); workspace.StopEditOperation(); } ComReleaser.ReleaseCOMObject(o); row = null; o = null; if (this.m_pTable is IFeatureLayer) { (this.m_pMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, this.m_pTable, null); } } } catch (Exception exception) { MessageBox.Show(exception.Message); } } }
private void dataGrid1_EmbeddedNavigator_ButtonClick(object sender, NavigatorButtonClickEventArgs e) { if (e.Button.ButtonType == NavigatorButtonType.Remove) { if ((this.m_InEditing && this.m_CanDo) && (((GridView)this.dataGrid1.MainView).SelectedRowsCount > 0)) { IFeatureLayer pTable = this.m_pTable as IFeatureLayer; if (pTable.FeatureClass != null) { string oIDFieldName = pTable.FeatureClass.OIDFieldName; int[] selectedRows = ((GridView)this.dataGrid1.MainView).GetSelectedRows(); this.m_CanDoFeatureLayerSelectChange = false; IWorkspaceEdit workspace = (this.m_pTable as IDataset).Workspace as IWorkspaceEdit; for (int i = 0; i < selectedRows.Length; i++) { object obj2 = ((GridView)this.dataGrid1.MainView).GetRow(selectedRows[i]); if (obj2 is DataRowView) { int num2 = Convert.ToInt32((obj2 as DataRowView).Row[oIDFieldName]); IQueryFilter queryFilter = new QueryFilterClass { WhereClause = this.m_pTable.OIDFieldName + " = " + num2.ToString() }; ICursor o = this.m_pTable.Search(queryFilter, false); IRow row = o.NextRow(); if (row != null) { workspace.StartEditOperation(); row.Delete(); workspace.StopEditOperation(); } row = null; ComReleaser.ReleaseCOMObject(o); o = null; } } this.m_CanDoFeatureLayerSelectChange = true; if (this.m_pTable is IFeatureLayer) { try { (this.m_pMap as IActiveView).Refresh(); } catch { } } } } } else if (e.Button.ButtonType == NavigatorButtonType.Last) { if (this.m_pDataTable.Rows.Count < this.m_RecordNum) { this.AddRecordToListView(true); } } else if (((e.Button.ButtonType == NavigatorButtonType.Next) && (((GridView)this.dataGrid1.MainView).GetSelectedRows()[0] == (this.m_pDataTable.Rows.Count - 2))) && (this.m_pDataTable.Rows.Count < this.m_RecordNum)) { this.AddRecordToListView(false); } }
private void cancel_Click(object sender, EventArgs e) { IMapDocument mxd = CancelParcelEditor10_5.ArcMap.Application.Document as IMapDocument; IMap map = mxd.get_Map(0); string gdb = AO.getLayerPathFromMxd(map, "חלקות לעריכה"); if (String.IsNullOrEmpty(gdb)) { MessageBox.Show("שכבת חלקות לעריכה אינה קיימת במפה"); } else { ITable table = AO.open_table(gdb, "CANCEL_PARCEL_EDIT"); if (table != null) { if (!String.IsNullOrEmpty(f_gush_num.Text) && !String.IsNullOrEmpty(f_parcel_num.Text) && !String.IsNullOrEmpty(t_gush_num.Text) && !String.IsNullOrEmpty(t_parcel_num.Text) && !String.IsNullOrEmpty(f_gush_suffix.Text) && !String.IsNullOrEmpty(t_gush_suffix.Text)) { if (String.IsNullOrEmpty(f_parcel_num_e.Text) && String.IsNullOrEmpty(t_parcel_num_e.Text)) { ICursor cursor = AO.create_table_cursor(table); IRow row = cursor.NextRow(); bool deleted = false; while (row != null) { if (!(row.Value[row.Fields.FindField("F_GUSH_NUM")] == null) && !(row.Value[row.Fields.FindField("F_PARCEL_NUM")] == null) && !(row.Value[row.Fields.FindField("T_GUSH_NUM")] == null) && !(row.Value[row.Fields.FindField("T_PARCEL_NUM")] == null)) { if ( row.Value[row.Fields.FindField("F_GUSH_NUM")] == Convert.ToInt32(f_gush_num.Text) && row.Value[row.Fields.FindField("F_PARCEL_NUM")] == Convert.ToInt32(f_parcel_num.Text) && row.Value[row.Fields.FindField("T_GUSH_NUM")] == Convert.ToInt32(t_gush_num.Text) && row.Value[row.Fields.FindField("T_PARCEL_NUM")] == Convert.ToInt32(t_parcel_num.Text) ) { row.Delete(); MessageBox.Show("רשומה נמחקה"); deleted = true; } row = cursor.NextRow(); } } if (deleted == false) { MessageBox.Show("לא נמצאה רשומה למחיקה"); } } else { if (!String.IsNullOrEmpty(f_parcel_num_e.Text) && String.IsNullOrEmpty(t_parcel_num_e.Text)) { int f_parcel_end = Convert.ToInt32(f_parcel_num_e.Text); int f_parcel_start = Convert.ToInt32(f_parcel_num.Text); List <object> parcel_num_in = new List <object>(); while (f_parcel_start <= f_parcel_end) { parcel_num_in.Add(f_parcel_start.ToString()); f_parcel_start++; } string query = "T_PARCEL_NUM =" + t_parcel_num.Text + " AND F_PARCEL_NUM IN (" + AO.ListToString(parcel_num_in) + ")"; ICursor cursor = AO.create_table_cursor_with_query(table, query); IRow row = cursor.NextRow(); bool deleted = false; while (row != null) { row.Delete(); row = cursor.NextRow(); deleted = true; } if (deleted == false) { MessageBox.Show("לא נמצאה רשומה למחיקה"); } } if (String.IsNullOrEmpty(f_parcel_num_e.Text) && !String.IsNullOrEmpty(t_parcel_num_e.Text)) { int t_parcel_end = Convert.ToInt32(t_parcel_num_e.Text); int t_parcel_start = Convert.ToInt32(t_parcel_num.Text); List <object> parcel_num_in = new List <object>(); while (t_parcel_start <= t_parcel_end) { parcel_num_in.Add(t_parcel_start.ToString()); t_parcel_start++; } string query = "F_PARCEL_NUM =" + f_parcel_num.Text + " AND T_PARCEL_NUM IN (" + AO.ListToString(parcel_num_in) + ")"; ICursor cursor = AO.create_table_cursor_with_query(table, query); IRow row = cursor.NextRow(); bool deleted = false; while (row != null) { row.Delete(); row = cursor.NextRow(); deleted = true; } if (deleted == false) { MessageBox.Show("לא נמצאה רשומה למחיקה"); } } } } else { MessageBox.Show("נא למלא את כל השדות"); } } else { MessageBox.Show("טבלת CANCEL_PARCEL_EDIT אינה קיימת ב gdb"); } } }
private void btn_Del_Click(object sender, EventArgs e) { bool flag = false; foreach (DataGridViewRow row in dataGridView.Rows) { if ((bool)row.Cells[0].EditedFormattedValue == true) { flag = true; } } if (!flag) { MessageBox.Show("没有选中行,无法删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogResult result = MessageBox.Show("是否确定删除!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { foreach (DataGridViewRow row in dataGridView.Rows) { if ((bool)row.Cells[0].EditedFormattedValue == true) { string cellvalue = row.Cells[1].Value.ToString().Trim(); IWorkspace pWorkspace = GetWorkspace(comboBoxSource.Text); if (pWorkspace == null) { MessageBox.Show("数据源空间不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } IWorkspace2 pWorkspace2 = (IWorkspace2)pWorkspace; // if (pWorkspace2.get_NameExists(esriDatasetType.esriDTRasterDataset, cellvalue)) { IEnumDataset enumDataset = pWorkspace.get_Datasets(esriDatasetType.esriDTRasterCatalog) as IEnumDataset; IDataset dataset = enumDataset.Next(); while (dataset != null) { if (dataset.Name.Trim() == comboBoxCatalog.Text.Trim()) { ITable pTable = dataset as ITable; //IRasterCatalog irastercatalog = (IRasterCatalog)dataset; ICursor pCursor = pTable.Search(null, false); IRow pRow = pCursor.NextRow(); while (pRow != null) { if (pRow.get_Value(pRow.Fields.FindField("Name")).ToString() == cellvalue) { this.Cursor = Cursors.WaitCursor; pRow.Delete();//如果相等则删除 this.Cursor = Cursors.Default; } pRow = pCursor.NextRow(); } } dataset = enumDataset.Next(); } } } } dataGridView.Rows.Clear(); LoadDataGridView();//重新加载数据 MessageBox.Show("删除数据成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static bool UnRegister(IFeatureClass ifeatureClass_0) { new ZDRegisterTable(); ITable table = AppConfigInfo.OpenTable("ZDInfos"); bool result; if (table == null) { result = false; } else { IQueryFilter queryFilter = new QueryFilter(); string[] array = (ifeatureClass_0 as IDataset).Name.Split(new char[] { '.' }); string workspaceConnectInfo = WorkspaceOperator.GetWorkspaceConnectInfo((ifeatureClass_0 as IDataset).Workspace); queryFilter.WhereClause = string.Format("FeatureClassName='{0}' and GDBConnectInfo='{1}'", array[array.Length - 1], workspaceConnectInfo); string arg = ""; string name = ""; using (ComReleaser comReleaser = new ComReleaser()) { ICursor cursor = table.Search(queryFilter, false); comReleaser.ManageLifetime(cursor); IRow row = cursor.NextRow(); if (row != null) { int num = table.FindField("HistoryFeatureClass"); if (num != -1) { name = row.get_Value(num).ToString(); } num = table.FindField("Guid"); if (num != -1) { arg = row.get_Value(num).ToString(); } row.Delete(); } } table = AppConfigInfo.OpenTable("ZDHistory"); queryFilter = new QueryFilter(); queryFilter.WhereClause = string.Format("ZDRegisterGuid='{0}'", arg); IWorkspaceEdit workspaceEdit = AppConfigInfo.GetWorkspace() as IWorkspaceEdit; bool flag = false; if (!workspaceEdit.IsBeingEdited()) { flag = true; workspaceEdit.StartEditing(true); } workspaceEdit.StartEditOperation(); table.DeleteSearchedRows(queryFilter); workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); if (!flag) { workspaceEdit.StartEditing(true); } try { IFeatureWorkspace featureWorkspace = (ifeatureClass_0 as IDataset).Workspace as IFeatureWorkspace; IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(name); (featureClass as IDataset).Delete(); } catch (System.Exception) { } result = true; } return(result); }
//TODO: 面实体的开始匹配 /// <summary> /// 开始匹配 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonXStartMatch_Click(object sender, EventArgs e) { //StopWatch类计时 Stopwatch sw = new Stopwatch(); sw.Start(); this.Cursor = System.Windows.Forms.Cursors.WaitCursor; IWorkspaceFactory2 pWorkspaceFactory = new FileGDBWorkspaceFactoryClass() as IWorkspaceFactory2; string gdbPath = ClsDeclare.g_WorkspacePath; IWorkspace2 pWorkspace = pWorkspaceFactory.OpenFromFile(gdbPath, 0) as IWorkspace2; IFeatureWorkspace featureWorkspace = pWorkspace as IFeatureWorkspace; IFeatureClass pSourceFeatCls2 = this.dataGridViewX1[1, 0].Tag as IFeatureClass; string targetFeatureName = this.dataGridViewX1[2, 0].Value.ToString(); //创建填充表MatchedPolygonFCSettingDif loadFeatSetting(gdbPath, targetFeatureName, pSourceFeatCls2); for (int j = 0; j < this.dataGridViewX1.RowCount; j++) { IFeatureClass srcFeatCls = this.dataGridViewX1.Rows[j].Cells[1].Tag as IFeatureClass; IFields fileds = null; if (srcFeatCls.ShapeType == esriGeometryType.esriGeometryPolygon) { //CreateMatchPolygonTFields函数返回了表xx的所有字段信息 fileds = CreateMatchPolygonTFields(pWorkspace); } //结果表xxx_DifPyTable存在,删除表再重现创建 ITable table = null; if (pWorkspace.get_NameExists(esriDatasetType.esriDTTable, this.dataGridViewX1.Rows[j].Cells[3].Value.ToString())) { //ClsDeleteTables.DeleteFeatureClass(gdbPath, this.dataGridViewX1.Rows[j].Cells[3].Value.ToString()); //table = CreateTable(pWorkspace, this.dataGridViewX1.Rows[j].Cells[3].Value.ToString(), fileds); table = featureWorkspace.OpenTable(this.dataGridViewX1.Rows[j].Cells[3].Value.ToString()); IWorkspaceEdit workspaceEdit = pWorkspace as IWorkspaceEdit; workspaceEdit.StartEditing(true); workspaceEdit.StartEditOperation(); ICursor cursor = table.Search(null, false); IRow r = cursor.NextRow(); while (r != null) { r.Delete(); r = cursor.NextRow(); } workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); } //结果表xxx_DifPyTable不存在,创建表 else { table = CreateTable(pWorkspace, this.dataGridViewX1.Rows[j].Cells[3].Value.ToString(), fileds); } //把生成匹配结果表xxx_DifPyTable(空表)存储到cell[3]的Tag属性中 this.dataGridViewX1[3, j].Tag = table; //根据工作图层的名称(待更新图层的名称)来打开待更新图层数据(feature) IFeatureClass tarFeatCls = featureWorkspace.OpenFeatureClass(this.dataGridViewX1.Rows[j].Cells[2].Value.ToString()); IDataset dataset = tarFeatCls as IDataset; string matchedFcName = dataset.Name; ITable tableSetting = null; double buffer = 0; double minArea = 0.0; if (srcFeatCls.ShapeType == esriGeometryType.esriGeometryPolygon) { tableSetting = featureWorkspace.OpenTable(ClsConstant.polygonSettingTable); if (tableSetting != null) { ICursor cursor = tableSetting.Search(null, false); IRow row = cursor.NextRow(); while (row != null) { if (row.get_Value(row.Fields.FindField("MatchedFCName")).ToString() == matchedFcName) { //面积重叠比匹配 if (this.tabItemAreaOverlap.Visible == true) { string temp = row.get_Value(row.Fields.FindField("Buffer")).ToString(); if (temp.Contains("米")) { temp = temp.Substring(0, temp.LastIndexOf("米")).Trim(); } buffer = Convert.ToDouble(temp); minArea = Convert.ToDouble(row.get_Value(row.Fields.FindField("AreaNum"))); } ////几何匹配 //else if (this.tabItemGeo.Visible == true) //{ // fields = row.get_Value(row.Fields.FindField("MatchedFields")).ToString(); // matchedMay = 0; // matchedMode = 10; // weight[0] = Convert.ToDouble(row.get_Value(row.Fields.FindField("SP"))); // string temp = row.get_Value(row.Fields.FindField("MatchedPointsBuffer")).ToString(); // if (temp.Contains("米")) // { // temp = temp.Substring(0, temp.LastIndexOf("米")).Trim(); // } // buffer = Convert.ToDouble(temp); // weight[1] = Convert.ToDouble(row.get_Value(row.Fields.FindField("MatchedPoints"))); // weight[2] = Convert.ToDouble(row.get_Value(row.Fields.FindField("TotalNum"))); // includeAngel = Convert.ToDouble(row.get_Value(row.Fields.FindField("IncludeAngle"))); // hausdorff = Convert.ToDouble(row.get_Value(row.Fields.FindField("Hausdorff"))); //} ////拓扑匹配 ////if (row.get_Value(row.Fields.FindField("Top")).ToString() == "1") //else if (this.tabItemTopo.Visible == true) //{ // matchedMay = 1; // matchedMode = -1; // //weight = 0; // string temp = row.get_Value(row.Fields.FindField("Buffer")).ToString(); // if (temp.Contains("米")) // { // temp = temp.Substring(0, temp.LastIndexOf("米")).Trim(); // } // buffer = Convert.ToDouble(temp); // fields = row.get_Value(row.Fields.FindField("MatchedFields")).ToString(); // break; //} } row = cursor.NextRow(); } } else { MessageBox.Show("tableSetting为空!"); } } //ClsCoreUpdateFun clsCoreUpdateFun = new ClsCoreUpdateFun(); ClsPolygonMatch clsPolygonMatch = new ClsPolygonMatch(); //面积重叠比匹配 if (this.tabItemAreaOverlap.Visible) { if (radioButtonAreaAgo.Checked) { //填充结果表xxx_DifPyTable clsPolygonMatch.DifScaleSearchChangedPolygonFeatures(srcFeatCls, tarFeatCls, table, buffer, minArea, progressBarMain, progressBarSub, labelXStatus); sw.Stop(); MessageBoxEx.Show("面积重叠匹配已完成!总需要时间" + sw.ElapsedMilliseconds + "ms", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (radioButtonAreaNow.Checked) { //填充结果表xxx_DifPyTable clsPolygonMatch.SearchChangedPolygonFeaturesArea(srcFeatCls, tarFeatCls, table, buffer, minArea, progressBarMain, progressBarSub, labelXStatus); sw.Stop(); MessageBoxEx.Show("面积重叠匹配已完成!总需要时间" + sw.ElapsedMilliseconds + "ms", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (radioButtonArea2.Checked) { //填充结果表xxx_DifPyTable clsPolygonMatch.SearchChangedPolygonFeaturesArea2(srcFeatCls, tarFeatCls, table, buffer, minArea, progressBarMain, progressBarSub, labelXStatus); sw.Stop(); MessageBoxEx.Show("面积重叠匹配已完成!总需要时间" + sw.ElapsedMilliseconds + "ms", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (radioButtonAreaDirec.Checked) { //填充结果表xxx_DifPyTable clsPolygonMatch.SearchChangedPolygonFeaturesAreaDirec(srcFeatCls, tarFeatCls, table, buffer, minArea, progressBarMain, progressBarSub, labelXStatus); sw.Stop(); MessageBoxEx.Show("面积重叠匹配已完成!总需要时间" + sw.ElapsedMilliseconds + "ms", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { } } this.Cursor = System.Windows.Forms.Cursors.Default; this.Close(); }
public bool DeleteRowsByFIDSet(ITable inTable, IFIDSet pFIDSet, IStepProgressor StepProgressor, ITrackCancel TrackCancel) {//this routine uses the GetRows method, avoids the need to break up the InClause. IMouseCursor pMouseCursor = new MouseCursorClass(); pMouseCursor.SetCursor(2); try { pFIDSet.Reset(); int[] iID = { }; bool bCont = true; iID = RedimPreserveInt(ref iID, pFIDSet.Count()); for (int iCount = 0; iCount <= pFIDSet.Count() - 1; iCount++) { pFIDSet.Next(out iID[iCount]); } ICursor pCursor = inTable.GetRows(iID, false); IRow row = pCursor.NextRow(); if (StepProgressor != null) { StepProgressor.MinRange = StepProgressor.Position; //reset the progress bar position StepProgressor.MaxRange = StepProgressor.Position + pFIDSet.Count(); if (StepProgressor.Position < StepProgressor.MaxRange) { StepProgressor.Step(); } } while (row != null) { //Check if the cancel button was pressed. If so, stop process if (StepProgressor != null) { if (TrackCancel != null) { bCont = TrackCancel.Continue(); } if (!bCont) { break; } } row.Delete(); Marshal.ReleaseComObject(row); row = pCursor.NextRow(); if (StepProgressor != null) { if (StepProgressor.Position < StepProgressor.MaxRange) { StepProgressor.Step(); } } } Marshal.ReleaseComObject(pCursor); inTable = null; iID = null; if (!bCont) { return(false); } return(true); } catch (COMException ex) { StepProgressor = null; MessageBox.Show(ex.Message); return(false); } }