Пример #1
0
 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);
     }
 }
Пример #2
0
        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);
        }
Пример #3
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();
        }
Пример #4
0
        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);
        }