示例#1
0
        private void CreatePipeLib()
        {
            IDataSource        ds             = null;
            IDataSourceFactory factory        = null;
            IConnectionInfo    connectionInfo = null;

            try
            {
                if (DF3DPipeCreateApp.App.PipeLib != null)
                {
                    DF3DPipeCreateApp.App.PipeLib.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(DF3DPipeCreateApp.App.PipeLib);
                    DF3DPipeCreateApp.App.PipeLib = null;
                }
                string fdbPath = this.buttonEditFilePath.Text.ToString().Trim();
                string pwd     = this.tePwd.Text;
                if (System.IO.File.Exists(fdbPath))
                {
                    System.IO.File.Delete(fdbPath);
                }
                factory        = new DataSourceFactoryClass();
                connectionInfo = new ConnectionInfoClass
                {
                    ConnectionType = gviConnectionType.gviConnectionFireBird2x,
                    Database       = fdbPath
                };
                ds = factory.CreateDataSource(connectionInfo, pwd);
                if (ds == null)
                {
                    XtraMessageBox.Show("创建管线库数据库失败!", "提示");
                    return;
                }

                if (InitPipeLib(ds))
                {
                    DF3DPipeCreateApp.App.PipeLib = ds;
                    XtraMessageBox.Show("创建管线库数据库成功!", "提示");
                    Config.SetConfigValue("3DPipeDataConnStr", connectionInfo.ToConnectionString());
                }
                else
                {
                    DF3DPipeCreateApp.App.PipeLib = null;
                    XtraMessageBox.Show("创建管线库数据库失败!", "提示");
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#2
0
        public IConnectionInfo GetConnectionInfo(string cnnType, string oracleInstance, string database, string server, uint port, string user, string pwd)
        {
            IConnectionInfo connectionInfo = new ConnectionInfoClass();
            IConnectionInfo result;

            try
            {
                if (cnnType == "MySql")
                {
                    connectionInfo.ConnectionType = gviConnectionType.gviConnectionMySql5x;
                }
                else
                {
                    if (cnnType == "Microsoft SQLServer")
                    {
                        connectionInfo.ConnectionType = gviConnectionType.gviConnectionMSClient;
                        connectionInfo.Instance       = oracleInstance;
                    }
                    else
                    {
                        if (cnnType == "File")
                        {
                            connectionInfo.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                        }
                        else
                        {
                            if (cnnType == "SQLite")
                            {
                                connectionInfo.ConnectionType = gviConnectionType.gviConnectionSQLite3;
                            }
                            else
                            {
                                if (cnnType == "Oracle")
                                {
                                    connectionInfo.ConnectionType = gviConnectionType.gviConnectionOCI11;
                                    connectionInfo.Instance       = oracleInstance;
                                }
                                else
                                {
                                    if (cnnType == FDEProcess.http)
                                    {
                                        connectionInfo.ConnectionType = gviConnectionType.gviConnectionCms7Http;
                                    }
                                    else
                                    {
                                        if (cnnType == FDEProcess.http)
                                        {
                                            connectionInfo.ConnectionType = gviConnectionType.gviConnectionCms7Https;
                                        }
                                        else
                                        {
                                            connectionInfo.ConnectionType = gviConnectionType.gviConnectionUnknown;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (database != null)
                {
                    connectionInfo.Database = database;
                }
                if (server != null)
                {
                    connectionInfo.Server = server;
                }
                connectionInfo.Port = port;
                if (user != null)
                {
                    connectionInfo.UserName = user;
                }
                if (pwd != null)
                {
                    connectionInfo.Password = pwd;
                }
                result = connectionInfo;
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                result = connectionInfo;
            }
            return(result);
        }
示例#3
0
        private IMultiPolygon GetMultiPolygonFromFile(string sFilePath)
        {
            IDataSource     dataSource     = null;
            IFeatureDataSet featureDataSet = null;
            IFeatureClass   featureClass   = null;
            IFdeCursor      fdeCursor      = null;
            IMultiPolygon   result;

            try
            {
                IConnectionInfo connectionInfo = new ConnectionInfoClass();
                connectionInfo.ConnectionType = gviConnectionType.gviConnectionShapeFile;
                connectionInfo.Database       = sFilePath;
                dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSource(connectionInfo);
                string[] featureDatasetNames = dataSource.GetFeatureDatasetNames();
                if (featureDatasetNames != null && featureDatasetNames.Length > 0)
                {
                    featureDataSet = dataSource.OpenFeatureDataset(featureDatasetNames[0]);
                    string[] namesByType = featureDataSet.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                    if (namesByType != null && namesByType.Length > 0)
                    {
                        featureClass = featureDataSet.OpenFeatureClass(namesByType[0]);
                        IFieldInfoCollection fields = featureClass.GetFields();
                        int num = -1;
                        gviGeometryColumnType gviGeometryColumnType = gviGeometryColumnType.gviGeometryColumnUnknown;
                        gviVertexAttribute    vertexAttribute       = gviVertexAttribute.gviVertexAttributeNone;
                        for (int i = 0; i < fields.Count; i++)
                        {
                            IFieldInfo fieldInfo = fields.Get(i);
                            if (fieldInfo.FieldType == gviFieldType.gviFieldGeometry && fieldInfo.GeometryDef != null)
                            {
                                num = i;
                                gviGeometryColumnType = fieldInfo.GeometryDef.GeometryColumnType;
                                vertexAttribute       = fieldInfo.GeometryDef.VertexAttribute;
                                break;
                            }
                        }
                        if (num == -1 || gviGeometryColumnType != gviGeometryColumnType.gviGeometryColumnPolygon)
                        {
                            XtraMessageBox.Show("应选择面状矢量数据!");
                            result = null;
                        }
                        else
                        {
                            IGeometryFactory geometryFactory = new GeometryFactoryClass();
                            IMultiPolygon    multiPolygon    = geometryFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, vertexAttribute) as IMultiPolygon;
                            multiPolygon.SpatialCRS = featureDataSet.SpatialReference;
                            fdeCursor = featureClass.Search(null, true);
                            IRowBuffer rowBuffer;
                            while ((rowBuffer = fdeCursor.NextRow()) != null)
                            {
                                object value = rowBuffer.GetValue(num);
                                if (value != null && value is IGeometry)
                                {
                                    IGeometry geometry = value as IGeometry;
                                    if (geometry.GeometryType == gviGeometryType.gviGeometryPolygon)
                                    {
                                        multiPolygon.AddPolygon(geometry as IPolygon);
                                    }
                                    else
                                    {
                                        if (geometry.GeometryType == gviGeometryType.gviGeometryMultiPolygon)
                                        {
                                            IMultiPolygon multiPolygon2 = geometry as IMultiPolygon;
                                            for (int j = 0; j < multiPolygon2.GeometryCount; j++)
                                            {
                                                IPolygon polygon = multiPolygon2.GetPolygon(j);
                                                if (polygon != null)
                                                {
                                                    multiPolygon.AddPolygon(polygon);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (multiPolygon.GeometryCount < 1)
                            {
                                XtraMessageBox.Show("无可用范围数据!");
                                result = null;
                            }
                            else
                            {
                                result = multiPolygon;
                            }
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("打开shp文件失败!");
                        result = null;
                    }
                }
                else
                {
                    XtraMessageBox.Show("名称为空");
                    result = null;
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                XtraMessageBox.Show(ex.Message);
                result = null;
            }
            finally
            {
                if (dataSource != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource);
                    dataSource = null;
                }
                if (featureDataSet != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet);
                    featureDataSet = null;
                }
                if (featureClass != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                    featureClass = null;
                }
                if (fdeCursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                    fdeCursor = null;
                }
            }
            return(result);
        }
示例#4
0
        public IDataSource GetDataSourceFromCnnstring(string cnnStr)
        {
            IDataSource result;

            try
            {
                string[] array = cnnStr.Split(new char[]
                {
                    ';'
                });
                for (int i = 0; i < array.Length; i++)
                {
                    string[] array2 = array[i].Split(new char[]
                    {
                        '='
                    });
                    array[i] = array2[1];
                }
                IConnectionInfo connectionInfo = new ConnectionInfoClass();
                string          a;
                if ((a = array[0]) != null)
                {
                    if (a == "MySQL5")
                    {
                        connectionInfo.ConnectionType = gviConnectionType.gviConnectionMySql5x;
                        goto IL_A0;
                    }
                    if (a == "Microsoft SQLServer")
                    {
                        connectionInfo.ConnectionType = gviConnectionType.gviConnectionMSClient;
                        goto IL_A0;
                    }
                    if (a == "FireBird2")
                    {
                        connectionInfo.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                        goto IL_A0;
                    }
                }
                connectionInfo.ConnectionType = gviConnectionType.gviConnectionUnknown;
IL_A0:
                if (array[1] == null)
                {
                    connectionInfo.Server = "";
                }
                else
                {
                    connectionInfo.Server = array[1];
                }
                connectionInfo.Port     = uint.Parse(array[2]);
                connectionInfo.Database = array[3];
                connectionInfo.UserName = array[4];
                connectionInfo.Password = array[5];
                result = this.dsf.OpenDataSource(connectionInfo);
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                result = null;
            }
            catch (System.Exception e)
            {
                LoggingService.Error(e.Message + "\r\n" + e.StackTrace);
                result = null;
            }
            return(result);
        }
示例#5
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);
     }
 }
示例#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();
        }
示例#7
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);
        }
示例#8
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);
        }