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 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 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) { 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); } } }