private void InsertFeatures(EditParameters parameter) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } if (parameter == null) { return; } System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = parameter.geometryMap; if (geometryMap != null) { CommandManagerServices.Instance().StartCommand(); FDECommand fDECommand = new FDECommand(true, true); SelectCollection.Instance().Clear(); foreach (DF3DFeatureClass current in geometryMap.Keys) { IFeatureClass featureClass = current.GetFeatureClass(); IRowBufferCollection rowBufferCollection = geometryMap[current]; CommonUtils.Instance().FdeUndoRedoManager.InsertFeatures(featureClass, rowBufferCollection); CommonUtils.Instance().Insert(current, rowBufferCollection, true, false); app.Current3DMapControl.FeatureManager.CreateFeatures(featureClass, rowBufferCollection); } fDECommand.SetSelectionMap(); CommandManagerServices.Instance().CallCommand(fDECommand); app.Workbench.UpdateMenu(); } }
public override void Run(object sender, System.EventArgs e) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } try { RenderControlEditServices.Instance().StopGeometryEdit(true); app.Current3DMapControl.PauseRendering(false); using (new UndoRedoOperator(1)) { CommandManagerServices.Instance().Redo(); app.Workbench.UpdateMenu(); } } catch (System.Exception) { } finally { app.Current3DMapControl.ResumeRendering(); } }
public bool IsValid(object caller, ICSharpCode.Core.Condition condition) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return(false); } //int count = SelectCollection.Instance().GetCount(false); //return count > 0 && CommandManagerServices.Instance().CanUndo(); return(CommandManagerServices.Instance().CanUndo()); }
private void DeleteSelection(EditParameters parameters) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); foreach (DF3DFeatureClass featureClassInfo in SelectCollection.Instance().FeatureClassInfoMap.Keys) { ResultSetInfo resultSetInfo = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo] as ResultSetInfo; if (resultSetInfo != null) { IFeatureClass featureClass = featureClassInfo.GetFeatureClass(); int[] array = new int[resultSetInfo.ResultSetTable.Rows.Count]; int num = 0; foreach (DataRow dataRow in resultSetInfo.ResultSetTable.Rows) { int num2 = int.Parse(dataRow[featureClass.FidFieldName].ToString()); array[num++] = num2; } if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { TemporalFilter temporalFilter = new TemporalFilterClass(); temporalFilter.AddSubField(featureClass.FidFieldName); temporalFilter.IdsFilter = array; ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(temporalFilter); while (temporalCursor.MoveNext()) { temporalCursor.Dead(parameters.TemproalTime); } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass); } else { CommonUtils.Instance().FdeUndoRedoManager.DeleteFeatures(featureClass, array); app.Current3DMapControl.FeatureManager.DeleteFeatures(featureClass, array); } } } SelectCollection.Instance().Clear(); CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); }
private void DeleteFeatures(EditParameters parameters) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } string featureClassGuid = parameters.featureClassGuid; if (string.IsNullOrEmpty(featureClassGuid)) { return; } DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(featureClassGuid); if (featureClassInfo == null) { return; } FDECommand cmd = new FDECommand(false, true); CommandManagerServices.Instance().StartCommand(); IFeatureClass featureClass = featureClassInfo.GetFeatureClass(); if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { System.DateTime temproalTime = parameters.TemproalTime; TemporalFilter temporalFilter = new TemporalFilterClass(); temporalFilter.AddSubField(featureClass.FidFieldName); temporalFilter.IdsFilter = parameters.fidList; ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(temporalFilter); while (temporalCursor.MoveNext()) { temporalCursor.Dead(temproalTime); } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass); } else { CommonUtils.Instance().FdeUndoRedoManager.DeleteFeatures(featureClass, parameters.fidList); app.Current3DMapControl.FeatureManager.DeleteFeatures(featureClass, parameters.fidList); } CommonUtils.Instance().Delete(featureClassInfo, parameters.fidList); CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); }
private void UpdateGeometry(EditParameters parameter) { try { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } if (parameter != null) { System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = parameter.geometryMap; if (geometryMap != null) { CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); foreach (DF3DFeatureClass current in geometryMap.Keys) { IRowBufferCollection rowBufferCollection = geometryMap[current]; IFeatureClass featureClass = current.GetFeatureClass(); if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { int position = featureClass.GetFields().IndexOf(featureClass.FidFieldName); System.Collections.Generic.Dictionary <int, IRowBuffer> dictionary = new System.Collections.Generic.Dictionary <int, IRowBuffer>(); for (int i = 0; i < rowBufferCollection.Count; i++) { IRowBuffer rowBuffer = rowBufferCollection.Get(i); int key = (int)rowBuffer.GetValue(position); dictionary[key] = rowBuffer; } ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(new TemporalFilterClass { IdsFilter = dictionary.Keys.ToArray <int>() }); while (temporalCursor.MoveNext()) { bool flag = false; int currentId = temporalCursor.CurrentId; ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false); TemporalInstance temporalInstance; while ((temporalInstance = temporalInstances.NextInstance()) != null) { if (temporalInstance.StartDatetime == parameter.TemproalTime) { flag = true; temporalInstances.Update(dictionary[currentId]); break; } } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances); if (!flag) { temporalCursor.Insert(parameter.TemproalTime, dictionary[currentId]); } } app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); } else { CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass, rowBufferCollection); } } CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); } } } catch (System.Runtime.InteropServices.COMException ex) { XtraMessageBox.Show(ex.Message); } catch (System.UnauthorizedAccessException) { XtraMessageBox.Show(StringParser.Parse("${res:Dataset_InsufficientPermission}")); } catch (System.Exception e) { LoggingService.Error(e.Message); } }
private void UpdateAttribute(EditParameters paramter) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } string featureClassGuid = paramter.featureClassGuid; if (string.IsNullOrEmpty(featureClassGuid)) { return; } DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(featureClassGuid); if (featureClassInfo == null) { return; } IFeatureClass featureClass = featureClassInfo.GetFeatureClass(); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(new TemporalFilterClass { IdsFilter = paramter.fidList }); while (temporalCursor.MoveNext()) { bool flag = false; int currentId = temporalCursor.CurrentId; IRowBuffer row = featureClass.GetRow(currentId); base.UpdateRowBuffer(ref row, paramter.colName, paramter.regexDataList); rowBufferCollection.Add(row); ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false); TemporalInstance temporalInstance; while ((temporalInstance = temporalInstances.NextInstance()) != null) { if (temporalInstance.StartDatetime == paramter.TemproalTime) { flag = true; temporalInstances.Update(row); break; } } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances); if (!flag) { temporalCursor.Insert(paramter.TemproalTime, row); } } app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); } else { CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); for (int i = 0; i < paramter.fidList.Length; i++) { int id = paramter.fidList[i]; IRowBuffer row2 = featureClass.GetRow(id); if (row2 != null) { base.UpdateRowBuffer(ref row2, paramter.colName, paramter.regexDataList); rowBufferCollection.Add(row2); } } CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass, rowBufferCollection); app.Current3DMapControl.FeatureManager.EditFeatures(featureClass, rowBufferCollection); CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); } CommonUtils.Instance().Update(featureClassInfo, rowBufferCollection); }
public void StopEdit(bool bSave) { if (this._app == null || this._app.Current3DMapControl == null) { return; } try { if (this._isSpatialQuery) { if (!bSave) { this._geoEditor.CancelEdit(); } else { this._geoEditor.FinishEdit(); } if (this.spatialQueryEditStopEvent != null) { this.spatialQueryEditStopEvent(bSave); } this._isSpatialQuery = false; this._app.Current3DMapControl.InteractMode = this._InteractaMode; } else { if (this._FeatureClass != null && this._row != null) { if (!bSave) { this._geoEditor.CancelEdit(); if (this._renderGeometry != null) { this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } this._app.Current3DMapControl.InteractMode = this._InteractaMode; } else { if (this._geoEditor.IsEditing && bSave) { this._geoEditor.FinishEdit(); } Gvitech.CityMaker.FdeCore.IFeatureClass featureClass = this._FeatureClass.GetFeatureClass(); int position = this._row.FieldIndex(this._FeatureClass.GetFeatureLayer().GeometryFieldName); IGeometry geometry = this._row.GetValue(position) as IGeometry; if (this._geoEditType == gviGeoEditType.gviGeoEditCreator) { ITopologicalOperator2D topologicalOperator2D = geometry as ITopologicalOperator2D; if (topologicalOperator2D == null || !topologicalOperator2D.IsSimple2D()) { XtraMessageBox.Show("创建的对象无效!"); this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } else { CommandManagerServices.Instance().StartCommand(); FDECommand fDECommand = new FDECommand(true, true); SelectCollection.Instance().Clear(); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); rowBufferCollection.Add(this._row); CommonUtils.Instance().FdeUndoRedoManager.InsertFeatures(featureClass, rowBufferCollection); CommonUtils.Instance().Insert(this._FeatureClass, rowBufferCollection, true, true); this._app.Current3DMapControl.FeatureManager.CreateFeature(featureClass, this._row); this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); fDECommand.SetSelectionMap(); CommandManagerServices.Instance().CallCommand(fDECommand); this._app.Workbench.UpdateMenu(); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } } else { CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); CommonUtils.Instance().FdeUndoRedoManager.UpdateFeature(featureClass, this._row); CommandManagerServices.Instance().CallCommand(cmd); this._app.Workbench.UpdateMenu(); } if (this._row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(this._row); this._row = null; } this._app.Current3DMapControl.InteractMode = this._InteractaMode; } } } } catch (System.Runtime.InteropServices.COMException ex) { XtraMessageBox.Show(ex.Message); } catch (System.UnauthorizedAccessException) { XtraMessageBox.Show("拒绝访问"); } catch (System.Exception ex2) { XtraMessageBox.Show(ex2.Message); } }
private void InsertFeatures(object param) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } EditParameters editParameters = (EditParameters)param; if (editParameters == null) { return; } System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = editParameters.geometryMap; if (geometryMap != null) { CommandManagerServices.Instance().StartCommand(); FDECommand fDECommand = new FDECommand(true, true); int nTotalCount = editParameters.nTotalCount; int num = 0; //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._clearSelection); //MainFrmService.ResultSetPanel.EndInvoke(asyncResult); foreach (DF3DFeatureClass current in geometryMap.Keys) { if (this._bgWorker.CancellationPending) { break; } IFeatureClass featureClass = current.GetFeatureClass(); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); IRowBufferCollection rowBufferCollection2 = geometryMap[current]; int num2 = 0; while (num2 < rowBufferCollection2.Count && !this._bgWorker.CancellationPending) { this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); IRowBuffer value = rowBufferCollection2.Get(num2); rowBufferCollection.Add(value); num++; string userState = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount); int percentProgress = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress, userState); num2++; } if (rowBufferCollection.Count > 0) { CommonUtils.Instance().FdeUndoRedoManager.InsertFeatures(featureClass, rowBufferCollection); //object[] args = new object[] //{ // current, // rowBufferCollection2, // true, // false //}; //asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._InsertSelection, args); //MainFrmService.ResultSetPanel.EndInvoke(asyncResult); rowBufferCollection.Clear(); } } fDECommand.SetSelectionMap(); CommandManagerServices.Instance().CallCommand(fDECommand); app.Workbench.UpdateMenu(); } }
private void UpdateGeometry(object param) { try { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } EditParameters editParameters = (EditParameters)param; if (editParameters != null) { System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = editParameters.geometryMap; if (geometryMap != null) { CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); int nTotalCount = editParameters.nTotalCount; int num = 0; foreach (DF3DFeatureClass current in geometryMap.Keys) { if (this._bgWorker.CancellationPending) { break; } IRowBufferCollection rowBufferCollection = geometryMap[current]; if (current.GetFeatureClass().HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { IConnectionInfo connectionInfo = new ConnectionInfoClass(); connectionInfo.FromConnectionString(current.GetFeatureClass().DataSource.ConnectionInfo.ToConnectionString()); IDataSource dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSource(connectionInfo); IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(CommonUtils.Instance().GetCurrentFeatureDataset().Name); IFeatureClass featureClass = featureDataSet.OpenFeatureClass(current.GetFeatureClass().Name); int position = featureClass.GetFields().IndexOf(featureClass.FidFieldName); System.Collections.Generic.Dictionary <int, IRowBuffer> dictionary = new System.Collections.Generic.Dictionary <int, IRowBuffer>(); for (int i = 0; i < rowBufferCollection.Count; i++) { IRowBuffer rowBuffer = rowBufferCollection.Get(i); int key = (int)rowBuffer.GetValue(position); dictionary[key] = rowBuffer; } ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(new TemporalFilterClass { IdsFilter = dictionary.Keys.ToArray <int>() }); while (temporalCursor.MoveNext() && !this._bgWorker.CancellationPending) { this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); num++; string userState = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount); int percentProgress = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress, userState); bool flag = false; int currentId = temporalCursor.CurrentId; ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false); TemporalInstance temporalInstance; while ((temporalInstance = temporalInstances.NextInstance()) != null) { if (temporalInstance.StartDatetime == editParameters.TemproalTime) { flag = true; temporalInstances.Update(dictionary[currentId]); break; } } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances); if (!flag) { temporalCursor.Insert(editParameters.TemproalTime, dictionary[currentId]); } } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet); System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource); } else { IFeatureClass featureClass2 = current.GetFeatureClass(); int num2 = 0; while (num2 < rowBufferCollection.Count && !this._bgWorker.CancellationPending) { this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); num++; string userState2 = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount); int percentProgress2 = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress2, userState2); num2++; } CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass2, rowBufferCollection); } } CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); } } } catch (System.Runtime.InteropServices.COMException ex) { XtraMessageBox.Show(ex.Message); } catch (System.UnauthorizedAccessException) { XtraMessageBox.Show(StringParser.Parse("${res:Dataset_InsufficientPermission}")); } catch (System.Exception e) { LoggingService.Error(e.Message); } }
private void UpdateAttribute(object param) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } EditParameters editParameters = (EditParameters)param; if (editParameters == null) { return; } string featureClassGuid = editParameters.featureClassGuid; DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(featureClassGuid); if (featureClassInfo == null) { return; } CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); int nTotalCount = editParameters.nTotalCount; int num = 0; if (featureClassInfo.GetFeatureClass().HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { IConnectionInfo connectionInfo = new ConnectionInfoClass(); connectionInfo.FromConnectionString(featureClassInfo.GetFeatureClass().DataSource.ConnectionInfo.ToConnectionString()); IDataSource dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSource(connectionInfo); IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(CommonUtils.Instance().GetCurrentFeatureDataset().Name); IFeatureClass featureClass = featureDataSet.OpenFeatureClass(featureClassInfo.GetFeatureClass().Name); ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(new TemporalFilterClass { IdsFilter = editParameters.fidList }); while (temporalCursor.MoveNext()) { this._manualResult.WaitOne(); num++; string userState = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount); int percentProgress = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress, userState); bool flag = false; int currentId = temporalCursor.CurrentId; IRowBuffer row = featureClass.GetRow(currentId); base.UpdateRowBuffer(ref row, editParameters.colName, editParameters.regexDataList); ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false); TemporalInstance temporalInstance; while ((temporalInstance = temporalInstances.NextInstance()) != null) { if (temporalInstance.StartDatetime == editParameters.TemproalTime) { flag = true; temporalInstances.Update(row); break; } } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances); if (!flag) { temporalCursor.Insert(editParameters.TemproalTime, row); } } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet); System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource); } else { IFeatureClass featureClass2 = featureClassInfo.GetFeatureClass(); System.Collections.Generic.Dictionary <int, string> dictionary = new System.Collections.Generic.Dictionary <int, string>(); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); IRowBufferCollection rowBufferCollection2 = new RowBufferCollectionClass(); for (int i = 0; i < editParameters.fidList.Length; i++) { if (this._bgWorker.CancellationPending) { CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass2, rowBufferCollection2); break; } this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); int num2 = editParameters.fidList[i]; IRowBuffer row2 = featureClass2.GetRow(num2); if (row2 != null) { string value = base.UpdateRowBuffer(ref row2, editParameters.colName, editParameters.regexDataList); rowBufferCollection.Add(row2); rowBufferCollection2.Add(row2); dictionary[num2] = value; num++; string userState2 = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount); int percentProgress2 = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress2, userState2); } } if (dictionary.Count > 0) { CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass2, rowBufferCollection2); object[] args = new object[] { featureClassInfo, editParameters.colName, dictionary }; //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._updateSelection, args); //MainFrmService.ResultSetPanel.EndInvoke(asyncResult); } } CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); }
private void DeleteFeatures(object param) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } EditParameters editParameters = (EditParameters)param; string featureClassGuid = editParameters.featureClassGuid; DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(featureClassGuid); string fcName = editParameters.fcName; if (string.IsNullOrEmpty(fcName) || featureClassInfo == null) { return; } int nTotalCount = editParameters.nTotalCount; int num = 0; CommandManagerServices.Instance().StartCommand(); object[] args = null; if (featureClassInfo.GetFeatureClass().HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { IConnectionInfo connectionInfo = new ConnectionInfoClass(); connectionInfo.FromConnectionString(featureClassInfo.GetFeatureClass().DataSource.ConnectionInfo.ToConnectionString()); IDataSource dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSource(connectionInfo); IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(CommonUtils.Instance().GetCurrentFeatureDataset().Name); IFeatureClass featureClass = featureDataSet.OpenFeatureClass(featureClassInfo.GetFeatureClass().Name); System.DateTime temproalTime = editParameters.TemproalTime; TemporalFilter temporalFilter = new TemporalFilterClass(); temporalFilter.AddSubField(featureClass.FidFieldName); temporalFilter.IdsFilter = editParameters.fidList; ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(temporalFilter); while (temporalCursor.MoveNext()) { this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); num++; string userState = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, nTotalCount); int percentProgress = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress, userState); temporalCursor.Dead(temproalTime); } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet); System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource); args = new object[] { featureClassInfo, editParameters.fidList }; } else { IFeatureClass featureClass2 = featureClassInfo.GetFeatureClass(); FDECommand cmd = new FDECommand(false, true); System.Collections.Generic.List <int> list = new System.Collections.Generic.List <int>(); System.Collections.Generic.List <int> list2 = new System.Collections.Generic.List <int>(); int[] fidList = editParameters.fidList; int i = 0; while (i < fidList.Length) { int item = fidList[i]; if (this._bgWorker.CancellationPending) { if (list.Count > 0) { CommonUtils.Instance().Delete(featureClassInfo, list.ToArray()); list.Clear(); break; } break; } else { this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); num++; string userState2 = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, nTotalCount); int percentProgress2 = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress2, userState2); list2.Add(item); list.Add(item); i++; } } if (list.Count > 0) { CommonUtils.Instance().FdeUndoRedoManager.DeleteFeatures(featureClass2, list.ToArray()); list.Clear(); CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); } args = new object[] { featureClassInfo, list2.ToArray() }; } //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._deleteSelection, args); //MainFrmService.ResultSetPanel.EndInvoke(asyncResult); }
private void DeleteSelection(object param) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } EditParameters editParameters = (EditParameters)param; if (editParameters == null) { return; } CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); int count = SelectCollection.Instance().GetCount(false); int num = 0; foreach (DF3DFeatureClass featureClassInfo in SelectCollection.Instance().FeatureClassInfoMap.Keys) { if (this._bgWorker.CancellationPending) { break; } ResultSetInfo resultSetInfo = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo] as ResultSetInfo; if (resultSetInfo != null) { System.Collections.Generic.List <int> list = new System.Collections.Generic.List <int>(); if (featureClassInfo.GetFeatureClass().HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { IConnectionInfo connectionInfo = new ConnectionInfoClass(); connectionInfo.FromConnectionString(featureClassInfo.GetFeatureClass().DataSource.ConnectionInfo.ToConnectionString()); IDataSource dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSource(connectionInfo); IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(CommonUtils.Instance().GetCurrentFeatureDataset().Name); IFeatureClass featureClass = featureDataSet.OpenFeatureClass(featureClassInfo.GetFeatureClass().Name); foreach (DataRow dataRow in resultSetInfo.ResultSetTable.Rows) { int item = int.Parse(dataRow[featureClass.FidFieldName].ToString()); list.Add(item); } TemporalFilter temporalFilter = new TemporalFilterClass(); temporalFilter.AddSubField(featureClass.FidFieldName); temporalFilter.IdsFilter = list.ToArray(); ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(temporalFilter); while (temporalCursor.MoveNext()) { this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); temporalCursor.Dead(editParameters.TemproalTime); num++; string userState = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, count); int percentProgress = num * 100 / count; this._bgWorker.ReportProgress(percentProgress, userState); } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet); System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource); } else { IFeatureClass featureClass2 = featureClassInfo.GetFeatureClass(); foreach (DataRow dataRow2 in resultSetInfo.ResultSetTable.Rows) { if (this._bgWorker.CancellationPending) { break; } this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); int item2 = int.Parse(dataRow2[featureClass2.FidFieldName].ToString()); list.Add(item2); num++; string userState2 = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, count); int percentProgress2 = num * 100 / count; this._bgWorker.ReportProgress(percentProgress2, userState2); } if (list.Count > 0) { CommonUtils.Instance().FdeUndoRedoManager.DeleteFeatures(featureClass2, list.ToArray()); list.Clear(); } } } } CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._clearSelection); //MainFrmService.ResultSetPanel.EndInvoke(asyncResult); }