Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 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);
     }
 }
Beispiel #4
0
        private void sbtn_Split_Click(object sender, System.EventArgs e)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            if (System.Windows.Forms.DialogResult.No != XtraMessageBox.Show("模型拆分不支持撤销操作,是否继续?", "询问", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Exclamation))
            {
                IFeatureClass featureClass = null;
                IFdeCursor    fdeCursor    = null;
                app.Current3DMapControl.PauseRendering(false);
                WaitDialogForm waitDialogForm = null;
                try
                {
                    int count = SelectCollection.Instance().GetCount(true);
                    if (count <= 0)
                    {
                        XtraMessageBox.Show("未选中要拆分的模型!");
                    }
                    else
                    {
                        if (this._renderGeo == null || this._renderGeo.GetFdeGeometry() == null)
                        {
                            XtraMessageBox.Show("请先绘制或选择拆分多边形!");
                        }
                        else
                        {
                            IMultiPolygon multiPolygon = null;
                            if (this.radioGroup1.SelectedIndex == 1)
                            {
                                IGeometryFactory geometryFactory = new GeometryFactoryClass();
                                multiPolygon = (geometryFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon);
                                multiPolygon.AddPolygon(this._renderGeo.GetFdeGeometry() as IPolygon);
                            }
                            else
                            {
                                if (this.radioGroup1.SelectedIndex == 0)
                                {
                                    multiPolygon = (this._renderGeo.GetFdeGeometry() as IMultiPolygon);
                                }
                            }
                            if (multiPolygon == null)
                            {
                                XtraMessageBox.Show("获取裁剪多边形失败!");
                            }
                            else
                            {
                                waitDialogForm = new WaitDialogForm(string.Empty, "正在拆分模型,请稍后...");
                                HashMap featureClassInfoMap            = SelectCollection.Instance().FeatureClassInfoMap;
                                System.Collections.Hashtable hashtable = new System.Collections.Hashtable();
                                foreach (DF3DFeatureClass featureClassInfo in featureClassInfoMap.Keys)
                                {
                                    if (featureClassInfo.GetFeatureLayer().GeometryType == gviGeometryColumnType.gviGeometryColumnModelPoint)
                                    {
                                        System.Collections.Generic.List <int> list  = new System.Collections.Generic.List <int>();
                                        System.Collections.Generic.List <int> list2 = new System.Collections.Generic.List <int>();
                                        IRowBufferCollection rowBufferCollection    = new RowBufferCollectionClass();
                                        IRowBufferCollection rowBufferCollection2   = new RowBufferCollectionClass();
                                        ResultSetInfo        resultSetInfo          = featureClassInfoMap[featureClassInfo] as ResultSetInfo;
                                        DataTable            resultSetTable         = resultSetInfo.ResultSetTable;
                                        if (resultSetTable.Rows.Count >= 1)
                                        {
                                            featureClass = featureClassInfo.GetFeatureClass();
                                            IResourceManager resourceManager = featureClass.FeatureDataSet as IResourceManager;
                                            string           fidFieldName    = featureClass.FidFieldName;
                                            int num = featureClass.GetFields().IndexOf(fidFieldName);
                                            foreach (DataRow dataRow in resultSetTable.Rows)
                                            {
                                                int         num2       = int.Parse(dataRow[fidFieldName].ToString());
                                                IRowBuffer  row        = featureClass.GetRow(num2);
                                                int         position   = row.FieldIndex(featureClassInfo.GetFeatureLayer().GeometryFieldName);
                                                IModelPoint modelPoint = row.GetValue(position) as IModelPoint;
                                                if (modelPoint != null)
                                                {
                                                    Gvitech.CityMaker.Resource.IModel model  = resourceManager.GetModel(modelPoint.ModelName);
                                                    IGeometryConvertor geometryConvertor     = new GeometryConvertorClass();
                                                    Gvitech.CityMaker.Resource.IModel model2 = null;
                                                    Gvitech.CityMaker.Resource.IModel model3 = null;
                                                    IModelPoint modelPoint2 = null;
                                                    IModelPoint modelPoint3 = null;
                                                    bool        flag        = geometryConvertor.SplitModelPointByPolygon2D(multiPolygon, model, modelPoint, out model2, out modelPoint2, out model3, out modelPoint3);
                                                    if (flag && model2 != null && !model2.IsEmpty && modelPoint2 != null && model3 != null && !model3.IsEmpty && modelPoint3 != null)
                                                    {
                                                        System.Guid guid = System.Guid.NewGuid();
                                                        string      text = guid.ToString();
                                                        resourceManager.AddModel(text, model2, null);
                                                        resourceManager.RebuildSimplifiedModel(text);
                                                        guid = System.Guid.NewGuid();
                                                        string text2 = guid.ToString();
                                                        resourceManager.AddModel(text2, model3, null);
                                                        resourceManager.RebuildSimplifiedModel(text2);
                                                        modelPoint3.ModelName = text2;
                                                        row.SetValue(position, modelPoint3);
                                                        rowBufferCollection.Add(row);
                                                        list.Add(num2);
                                                        modelPoint2.ModelName = text;
                                                        IRowBuffer rowBuffer = row.Clone(false);
                                                        rowBuffer.SetNull(num);
                                                        rowBuffer.SetValue(position, modelPoint2);
                                                        fdeCursor = featureClass.Insert();
                                                        fdeCursor.InsertRow(rowBuffer);
                                                        int lastInsertId = fdeCursor.LastInsertId;
                                                        rowBuffer.SetValue(num, lastInsertId);
                                                        rowBufferCollection2.Add(rowBuffer);
                                                        list2.Add(lastInsertId);
                                                        System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                                                        fdeCursor = null;
                                                    }
                                                }
                                            }
                                            featureClass.UpdateRows(rowBufferCollection, false);
                                            app.Current3DMapControl.FeatureManager.EditFeatures(featureClass, rowBufferCollection);
                                            app.Current3DMapControl.FeatureManager.CreateFeatures(featureClass, rowBufferCollection2);
                                            hashtable[featureClassInfo] = list2;
                                            //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                                            featureClass = null;
                                            System.Runtime.InteropServices.Marshal.ReleaseComObject(resourceManager);
                                            resourceManager = null;
                                        }
                                    }
                                }
                                SelectCollection.Instance().UpdateSelection(hashtable);
                                base.Close();
                                base.DialogResult = System.Windows.Forms.DialogResult.OK;
                            }
                        }
                    }
                }
                catch (System.Runtime.InteropServices.COMException ex)
                {
                    XtraMessageBox.Show(ex.Message);
                }
                catch (System.UnauthorizedAccessException var_35_4EC)
                {
                    XtraMessageBox.Show("拒绝访问");
                }
                catch (System.Exception ex2)
                {
                    XtraMessageBox.Show(ex2.Message);
                }
                finally
                {
                    if (waitDialogForm != null)
                    {
                        waitDialogForm.Close();
                    }
                    if (fdeCursor != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                        fdeCursor = null;
                    }
                    //if (featureClass != null && System.Runtime.InteropServices.Marshal.IsComObject(featureClass))
                    //{
                    //    System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                    //    featureClass = null;
                    //}
                    app.Current3DMapControl.ResumeRendering();
                }
            }
        }
Beispiel #5
0
        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();
            }
        }
Beispiel #6
0
        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();
        }
Beispiel #7
0
 private void UpdateGeometry(object param)
 {
     try
     {
         EditParameters editParameters = (EditParameters)param;
         if (editParameters != null)
         {
             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;
                 foreach (DF3DFeatureClass current in geometryMap.Keys)
                 {
                     if (this._bgWorker.CancellationPending)
                     {
                         break;
                     }
                     IFeatureClass        featureClass        = featureDataSet.OpenFeatureClass(current.GetFeatureClass().Name);
                     IRowBufferCollection rowBufferCollection = geometryMap[current];
                     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() && !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);
                     }
                     else
                     {
                         IRowBufferCollection rowBufferCollection2 = new RowBufferCollectionClass();
                         int num2 = 0;
                         while (num2 < rowBufferCollection.Count && !this._bgWorker.CancellationPending)
                         {
                             IRowBuffer value = rowBufferCollection.Get(num2).Clone(true);
                             rowBufferCollection2.Add(value);
                             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++;
                         }
                         featureClass.UpdateRows(rowBufferCollection2, false);
                     }
                     //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                 }
                 System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet);
                 System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource);
             }
         }
     }
     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);
     }
 }