private void InsertFeatures(object param) { EditParameters editParameters = (EditParameters)param; if (editParameters == null) { return; } System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = editParameters.geometryMap; if (geometryMap != null) { IDataSource dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSourceByString(editParameters.connectionInfo); IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(editParameters.datasetName); 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 = featureDataSet.OpenFeatureClass(current.GetFeatureClass().Name); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); IRowBufferCollection rowBufferCollection2 = geometryMap[current]; int num2 = 0; while (num2 < rowBufferCollection2.Count && !this._bgWorker.CancellationPending) { this._manualResult.WaitOne(); 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); } //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet); System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource); } }
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(); }
public override void DoWork(EditType editType, EditParameters parameters) { switch (editType) { case EditType.ET_DELETE_SELCTION: { this.DeleteSelection(parameters); return; } case EditType.ET_DELETE_RECYCLE: case EditType.ET_UPDATE_MERGE_SELECTION: { break; } case EditType.ET_DELETE_FEATURES: { this.DeleteFeatures(parameters); return; } case EditType.ET_UPDATE_ATTRIBUTE: { this.UpdateAttribute(parameters); return; } case EditType.ET_UPDATE_GEOMETRY: { this.UpdateGeometry(parameters); return; } case EditType.ET_INSERT_FEATURES: { this.InsertFeatures(parameters); break; } default: { return; } } }
public override void DoWork(EditType editType, EditParameters parameters) { this._manualResult = new System.Threading.ManualResetEvent(true); this._bgWorker = new BackgroundWorker(); this._bgWorker.WorkerReportsProgress = true; this._bgWorker.WorkerSupportsCancellation = true; this._bgWorker.DoWork += new DoWorkEventHandler(this.BGWorker_DoWork); this._bgWorker.ProgressChanged += new ProgressChangedEventHandler(this.BGWorker_ProgressChanged); this._bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.BGWorker_RunWorkerCompleted); this._progressDlg = new ProgressDialog1(this._bgWorker, this._manualResult); this._progressDlg.btnCancle.Visible = false; object[] argument = new object[] { editType, parameters }; this._bgWorker.RunWorkerAsync(argument); this._progressDlg.ShowDialog(); }
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); }
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); }
public abstract void DoWork(EditType editType, EditParameters parameters);
private void UpdateAttribute(object param) { IFeatureClass featureClass = null; try { EditParameters editParameters = (EditParameters)param; if (editParameters != null) { DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(editParameters.featureClassGuid); IDataSource dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSourceByString(editParameters.connectionInfo); IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(editParameters.datasetName); featureClass = featureDataSet.OpenFeatureClass(editParameters.fcName); int nTotalCount = editParameters.nTotalCount; int num = 0; if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { 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); } else { featureClass.FeatureDataSet.DataSource.StartEditing(); IFdeCursor fdeCursor = featureClass.Update(new QueryFilterClass { IdsFilter = editParameters.fidList }); IRowBuffer rowBuffer = null; System.Collections.Generic.Dictionary <int, string> dictionary = new System.Collections.Generic.Dictionary <int, string>(); while ((rowBuffer = fdeCursor.NextRow()) != null && !this._bgWorker.CancellationPending) { int position = rowBuffer.FieldIndex(featureClass.FidFieldName); int key = int.Parse(rowBuffer.GetValue(position).ToString()); string value = base.UpdateRowBuffer(ref rowBuffer, editParameters.colName, editParameters.regexDataList); fdeCursor.UpdateRow(rowBuffer); num++; dictionary[key] = value; string userState2 = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount); int percentProgress2 = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress2, userState2); } System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor); featureClass.FeatureDataSet.DataSource.StopEditing(true); object[] args = new object[] { featureClassInfo, editParameters.colName, dictionary }; //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._updateSelection, args); //MainFrmService.ResultSetPanel.EndInvoke(asyncResult); } //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet); System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource); } } catch (System.Exception) { if (featureClass != null) { featureClass.FeatureDataSet.DataSource.StopEditing(true); } } }
private void DeleteFeatures(object param) { IFeatureClass featureClass = null; IDataSource dataSource = null; IFeatureDataSet featureDataSet = null; try { EditParameters editParameters = (EditParameters)param; DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(editParameters.featureClassGuid); string fcName = editParameters.fcName; if (!string.IsNullOrEmpty(fcName) && featureClassInfo != null) { dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSourceByString(editParameters.connectionInfo); featureDataSet = dataSource.OpenFeatureDataset(editParameters.datasetName); int nTotalCount = editParameters.nTotalCount; int num = 0; featureClass = featureDataSet.OpenFeatureClass(fcName); string geometryFieldName = featureClassInfo.GetFeatureLayer().GeometryFieldName; featureClass.SetRenderIndexEnabled(geometryFieldName, false); if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { 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()) { temporalCursor.Dead(temproalTime); num++; string userState = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, nTotalCount); int percentProgress = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress, userState); } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); } else { featureClass.FeatureDataSet.DataSource.StartEditing(); IFdeCursor fdeCursor = featureClass.Update(new QueryFilterClass { IdsFilter = editParameters.fidList }); while (fdeCursor.NextRow() != null && !this._bgWorker.CancellationPending) { fdeCursor.DeleteRow(); num++; string userState2 = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, nTotalCount); int percentProgress2 = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress2, userState2); } System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor); featureClass.FeatureDataSet.DataSource.StopEditing(true); } if (this._progressDlg.Created) { string userState3 = StringParser.Parse("${res:feature_progress_updateindex}"); int percentProgress3 = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress3, userState3); } featureClass.SetRenderIndexEnabled(geometryFieldName, true); featureClass.RebuildRenderIndex(geometryFieldName, gviRenderIndexRebuildType.gviRenderIndexRebuildWithData); object[] args = new object[] { featureClassInfo, editParameters.fidList }; //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._deleteSelection, args); //MainFrmService.ResultSetPanel.EndInvoke(asyncResult); } } catch (System.Exception) { if (featureClass != null) { featureClass.FeatureDataSet.DataSource.StopEditing(false); } } finally { //if (featureClass != null) //{ // System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); // featureClass = null; //} if (featureDataSet != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet); featureDataSet = null; } if (dataSource != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource); dataSource = null; } } }
private void DeleteSelection(object param) { EditParameters editParameters = (EditParameters)param; if (editParameters == null) { return; } try { int count = SelectCollection.Instance().GetCount(false); int num = 0; IDataSource dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSourceByString(editParameters.connectionInfo); IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(editParameters.datasetName); foreach (DF3DFeatureClass featureClassInfo in SelectCollection.Instance().FeatureClassInfoMap.Keys) { if (this._bgWorker.CancellationPending) { break; } ResultSetInfo resultSetInfo = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo] as ResultSetInfo; if (resultSetInfo != null) { string geometryFieldName = featureClassInfo.GetFeatureLayer().GeometryFieldName; IFeatureClass featureClass = featureDataSet.OpenFeatureClass(featureClassInfo.GetFeatureClass().Name); string fidFieldName = featureClass.FidFieldName; System.Collections.Generic.List <int> list = new System.Collections.Generic.List <int>(); foreach (DataRow dataRow in resultSetInfo.ResultSetTable.Rows) { int item = int.Parse(dataRow[fidFieldName].ToString()); list.Add(item); } featureClass.SetRenderIndexEnabled(geometryFieldName, false); if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { 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); num++; string userState = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, count); int percentProgress = num * 100 / count; this._bgWorker.ReportProgress(percentProgress, userState); temporalCursor.Dead(editParameters.TemproalTime); } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); } else { featureClass.FeatureDataSet.DataSource.StartEditing(); IFdeCursor fdeCursor = featureClass.Update(new QueryFilterClass { IdsFilter = list.ToArray() }); while (fdeCursor.NextRow() != null && !this._bgWorker.CancellationPending) { System.Threading.Thread.Sleep(1); fdeCursor.DeleteRow(); num++; string userState2 = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, count); int percentProgress2 = num * 100 / count; this._bgWorker.ReportProgress(percentProgress2, userState2); } System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor); featureClass.FeatureDataSet.DataSource.StopEditing(true); } if (this._progressDlg.Created) { string userState3 = StringParser.Parse("${res:feature_progress_updateindex}"); int percentProgress3 = num * 100 / count; this._bgWorker.ReportProgress(percentProgress3, userState3); } featureClass.SetRenderIndexEnabled(geometryFieldName, true); featureClass.RebuildRenderIndex(geometryFieldName, gviRenderIndexRebuildType.gviRenderIndexRebuildWithData); //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } } System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet); System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource); //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._clearSelection); //MainFrmService.ResultSetPanel.EndInvoke(asyncResult); } catch (System.Exception) { } }