Exemplo n.º 1
0
 public static void DeleteFeatureClass(IDataset data)
 {
     if (data.CanDelete())
     {
         data.Delete();
     }
 }
Exemplo n.º 2
0
 public void shpDel(string shppath)
 {
     if (string.IsNullOrEmpty(shppath))
     {
         return;
     }
     if (!System.IO.File.Exists(shppath))
     {
         return;
     }
     using (ComReleaser comreleaser = new ComReleaser())
     {
         IWorkspaceFactory WspFac  = new ShapefileWorkspaceFactoryClass();
         IFeatureWorkspace fteWsp  = WspFac.OpenFromFile(System.IO.Path.GetDirectoryName(shppath), 0) as IFeatureWorkspace;
         IFeatureClass     fClss   = fteWsp.OpenFeatureClass(System.IO.Path.GetFileName(shppath));
         IFeatureLayer     fteLyr  = new FeatureLayerClass();
         IDataset          dataset = null;
         if (fClss == null)
         {
             return;
         }
         fteLyr.FeatureClass = fClss;
         fteLyr.Name         = fteLyr.FeatureClass.AliasName;
         //定义数据集,保证处于编辑状态
         dataset = fteLyr.FeatureClass as IDataset;
         dataset.Delete();
     }
 }
Exemplo n.º 3
0
        //3/10/2009	删除工作空间内的所有要素类
        public static void DeleteAllFeatCls(IWorkspace pworkspace)
        {
            IEnumDataset    pEnumFeatDataset = default(IEnumDataset);
            IDataset        pDataset         = default(IDataset);
            IFeatureDataset pFeatDataset     = default(IFeatureDataset);

            pEnumFeatDataset = pworkspace.get_Datasets(esriDatasetType.esriDTAny);
            pEnumFeatDataset.Reset();
            pDataset = pEnumFeatDataset.Next();
            while ((pDataset != null))
            {
                if (pDataset.CanDelete())
                {
                    if (pDataset.Type == esriDatasetType.esriDTFeatureDataset)
                    {
                        pFeatDataset = (IFeatureDataset)pDataset;
                        pFeatDataset.Delete();
                    }
                    else
                    {
                        pDataset.Delete();
                    }
                    //pDataset.Delete()
                    pDataset = pEnumFeatDataset.Next();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Exports to SHP.
        /// </summary>
        /// <param name="inputFeatureClass">The input feature class.</param>
        /// <param name="dataSourceType">Type of the data source.</param>
        /// <param name="saveShpFilePath">The save SHP file path.</param>
        public void ExportToShp(IFeatureClass inputFeatureClass, string dataSourceType, string saveShpFilePath)
        {
            IDataset          dataset                  = inputFeatureClass as IDataset;
            string            directoryName            = Path.GetDirectoryName(saveShpFilePath);
            string            fileNameWithoutExtension = Path.GetFileNameWithoutExtension(saveShpFilePath);
            IWorkspaceFactory workspaceFactory         = new ShapefileWorkspaceFactoryClass();
            IWorkspace        workspace                = workspaceFactory.OpenFromFile(directoryName, 0);

            if (!Directory.Exists(directoryName))
            {
                Directory.CreateDirectory(directoryName);
            }
            if (File.Exists(saveShpFilePath))
            {
                IFeatureClass featureClass = (workspace as IFeatureWorkspace).OpenFeatureClass(fileNameWithoutExtension);
                IDataset      dataset2     = featureClass as IDataset;
                if (!dataset2.CanDelete())
                {
                    XtraMessageBox.Show(AppMessage.MSG0112, AppMessage.MSG0000, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk);
                    return;
                }
                string a = Path.Combine(dataset.Workspace.PathName, dataset.Name + ".shp");
                if (a == saveShpFilePath && dataSourceType == "Shapefile Feature Class")
                {
                    XtraMessageBox.Show(AppMessage.MSG0112, AppMessage.MSG0000, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk);
                    return;
                }
                dataset2.Delete();
            }
            this.SaveAsShpfile(inputFeatureClass, dataset, fileNameWithoutExtension, workspace);
        }
Exemplo n.º 5
0
        /// <summary>
        ///  DeleteShapeFile
        /// </summary>
        /// <returns></returns>
        public bool DeleteShapeFile()
        {
            bool          rbc = false;
            IFeatureClass fc  = null;

            try
            {
                fc = this.getIFeatureClass();
                if (fc != null)
                {
                    IDataset fds = fc as IDataset;
                    fds.Delete();
                    fds = null;
                    TokayWorkspace.ComRelease(fc);
                    fc = null;
                }
                this.DeleteTempFile(this.LocalShapePathFileName);

                rbc = true;
            }
            catch (Exception ee)
            {
                System.Diagnostics.Debug.WriteLine(ee.ToString());
                rbc = false;
            }
            finally
            {
                if (fc != null)
                {
                    TokayWorkspace.ComRelease(fc);
                    fc = null;
                }
            }
            return(rbc);
        }
Exemplo n.º 6
0
        public static void DeleteFeatureClass(IWorkspace pWorkspace, string pFeatureClassName)
        {
            IFeatureClass featureClass = DBOperator.getFeatureClass(pWorkspace, pFeatureClassName);
            IDataset      dataSet      = featureClass as IDataset;

            dataSet.Delete();
        }
Exemplo n.º 7
0
 protected virtual void Dispose(bool disposing)
 {
     if (true == disposed)
     {
         return;
     }
     if (disposing)
     {
         /*
          * http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/InMemoryWorkspaceFactoryClass_Class/001m0000002q000000/
          * When an in-memory workspace is no longer needed, it is the developer's responsibility to call IDataset.Delete on the workspace to release its memory.
          *
          * I am not sure the memory held by idataset is managed or unmanaged, currently treat it as "unmanaged"
          */
         if (null != workspace && workspace is IDataset)
         {
             IDataset dataset = workspace as IDataset;
             if (null != dataset && dataset.CanDelete())
             {
                 dataset.Delete();
             }
             this.releaseCOMObj(this.workspace);
             this.releaseCOMObj(this.workspaceName);
         }
     }
     disposed = true;
 }
Exemplo n.º 8
0
        public void DisposeSurface()
        {
            if (_rasterSurface == null)
            {
                return;
            }

            _msg.Debug("Disposing raster");

            _rasterSurface.Dispose();
            _rasterSurface = null;

            IWorkspace memoryWs = null;

            if (_memoryRasterDataset != null)
            {
                memoryWs = _memoryRasterDataset.Workspace;
                _memoryRasterDataset.Delete();
                ComUtils.ReleaseComObject(_memoryRasterDataset);
                _memoryRasterDataset = null;
            }

            if (memoryWs != null)
            {
                ((IDataset)memoryWs).Delete();
                ComUtils.ReleaseComObject(memoryWs);
            }
        }
Exemplo n.º 9
0
        //保存一个FeatureClass为文件 by gisoracle
        //public void saveFeatureClass(IFeatureClass pFeatureClass, string fileName)
        //{
        //    try
        //    {
        //        string sFileName = System.IO.Path.GetFileName(fileName);
        //        string sFilePath = System.IO.Path.GetDirectoryName(fileName);

        //        IDataset pDataset = pFeatureClass as IDataset;

        //        IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
        //        IFeatureWorkspace pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(sFilePath, 0) as IFeatureWorkspace;

        //        IWorkspace pWorkspace = pFeatureWorkspace as IWorkspace;
        //        if (pWorkspace.Exists() == true)
        //        {
        //            //DelFeatureFile(sFilePath, sFileName);
        //        }
        //        //pDataset.Copy(sFileName, pFeatureWorkspace as IWorkspace);

        //    }
        //    catch { MessageBox.Show("错误"); }
        //}

        //by gisoracle
        public static void DelFeatureFile(IFeatureClass pFeatureClass, string sName)
        {
            if (pFeatureClass != null)
            {
                IDataset dataset = pFeatureClass as IDataset;
                dataset.Delete();
            }
        }
Exemplo n.º 10
0
 public static void JTDelete(this IDataset ds)
 {
     if (ds == null || !ds.CanDelete())
     {
         return;
     }
     ds.Delete();
 }
Exemplo n.º 11
0
        public void deleteTable(IWorkspace pWorkspace, string tableName)
        {
            IFeatureWorkspace pFWs    = pWorkspace as IFeatureWorkspace;
            ITable            pFClass = pFWs.OpenTable(tableName);
            IDataset          ds      = pFClass as IDataset;

            ds.Delete();
        }
Exemplo n.º 12
0
        public void deleteFeatureDataset(IWorkspace workspace, string featuredatasetname)
        {
            IFeatureWorkspace pFWs    = workspace as IFeatureWorkspace;
            IFeatureDataset   pFClass = pFWs.OpenFeatureDataset(featuredatasetname);
            IDataset          ds      = pFClass as IDataset;

            ds.Delete();
        }
Exemplo n.º 13
0
        public void deleteFeatureClass(IWorkspace pWs, string featureName)
        {
            IFeatureWorkspace pFWs    = pWs as IFeatureWorkspace;
            IFeatureClass     pFClass = pFWs.OpenFeatureClass(featureName);
            IDataset          ds      = pFClass as IDataset;

            ds.Delete();
        }
Exemplo n.º 14
0
        /// <summary>
        /// Delete a featureclass
        /// </summary>
        /// <param name="fWorkspace">IFeatureWorkspace</param>
        /// <param name="fcName">Name of featureclass to delete</param>
        private void DeleteFeatureClass(IFeatureWorkspace fWorkspace, string fcName)
        {
            IDataset ipDs = fWorkspace.OpenFeatureClass(fcName) as IDataset;

            if (ipDs != null)
            {
                ipDs.Delete();
            }
        }
Exemplo n.º 15
0
        private static void DeleteShpFile(string pathName, string fileName)
        {
            IWorkspaceFactory pWSF            = new ShapefileWorkspaceFactory();
            IFeatureWorkspace pFWS            = pWSF.OpenFromFile(pathName, 0) as IFeatureWorkspace;
            IFeatureClass     pFeatureClass   = pFWS.OpenFeatureClass(fileName);
            IDataset          pFeatureDataset = pFeatureClass as IDataset;

            pFeatureDataset.Delete();
        }
Exemplo n.º 16
0
 /// <summary>
 /// 删除数据集
 /// </summary>
 /// <param name="pDataset"></param>
 public static void DeleteDataset(IDataset pDataset)
 {
     if (pDataset.CanDelete())
     {
         pDataset.Delete();
     }
     else
     {
         MessageBox.Show("无法删除该数据集!");
     }
 }
Exemplo n.º 17
0
        public static void DeleteFeatureClass(IFeatureClass featureClass)
        {
            IDataset pDataset = featureClass as IDataset;

            if (pDataset == null)
            {
                return;
            }
            pDataset.CanDelete();
            pDataset.Delete();
        }
Exemplo n.º 18
0
        private void  除选中行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool flag = false;

            foreach (DataGridViewRow row in datagwSource.Rows)
            {
                if ((bool)row.Cells[0].EditedFormattedValue == true)
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                MessageBox.Show("没有选中行,无法删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DialogResult result = MessageBox.Show("是否确定删除!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                foreach (DataGridViewRow row in datagwSource.Rows)
                {
                    if ((bool)row.Cells[0].EditedFormattedValue == true)
                    {
                        //IWorkspaceFactory Pwf = new FileGDBWorkspaceFactoryClass();
                        //pWorkspace = (IWorkspace)(Pwf.OpenFromFile(GetSourcePath(comboBoxSource.Text), 0));
                        pWorkspace = GetWorkspace(comboBoxSource.Text);
                        if (pWorkspace != null)
                        {
                            pWorkspace2 = (IWorkspace2)pWorkspace;
                            if (pWorkspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, row.Cells[1].Value.ToString().Trim()))
                            {
                                IFeatureClass     tmpfeatureclass;
                                IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspace;
                                tmpfeatureclass = pFeatureWorkspace.OpenFeatureClass(row.Cells[1].Value.ToString().Trim());
                                IDataset set = tmpfeatureclass as IDataset;
                                set.CanDelete();
                                set.Delete();

                                //listBoxDetail.Items.Add("删除了" + row.Cells[1].Value + "数据");
                                //listBoxDetail.Items.Add(" ");
                                //listBoxDetail.Refresh();
                            }
                        }
                        DeleteSql(row.Cells[1].Value.ToString());
                    }
                }
                datagwSource.Rows.Clear();
                ChangeGridView();//重新加载数据
                MessageBox.Show("删除数据成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 19
0
 public static bool ReleaseInMemoryWorkspaceMemory(IWorkspace workspace)
 {
     if (null != workspace)
     {
         IDataset dataset = workspace as IDataset;
         if (null != dataset && dataset.CanDelete())
         {
             dataset.Delete();
         }
     }
     return(false);
 }
Exemplo n.º 20
0
        /// <summary>
        /// 在该文件目录下删除指定名称的文件
        /// </summary>
        /// <param name="path"></param>
        public void Delete(string fileName)
        {
            IDataset ds = EnumDs.Next();

            while (ds != null)
            {
                if (ds.Name.ToLower().Equals(fileName.ToLower()))
                {
                    ds.Delete();
                }
                ds = EnumDs.Next();
            }
        }
Exemplo n.º 21
0
 protected bool DeleteShapefile(IFeatureClass pFeatClass)
 {
     try
     {
         IDataset pDS = (IDataset)pFeatClass;
         pDS.Delete();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 22
0
        public static void Import2(string savemdbFile, string sourcemdbFile, List <StockTable> tables, string XZSDM, string XZSMC)
        {
            IWorkspace              workspaceA               = savemdbFile.OpenAccessFileWorkSpace();
            IFeatureWorkspace       featureWorkspace         = workspaceA as IFeatureWorkspace;
            IFeatureWorkspaceManage featureWorkspaceManagerA = featureWorkspace as IFeatureWorkspaceManage;

            IWorkspace workspaceB = sourcemdbFile.OpenAccessFileWorkSpace();

            foreach (var table in tables)
            {
                if (table.IsSpace == false)
                {
                    continue;
                }
                var outfeatureClassName = table.Name + "_Merge";
                if (!MergeFeatureClass(string.Format("{0}\\{1};{2}\\{1}", savemdbFile, table.Name, sourcemdbFile), null, string.Format("{0}\\{1}", savemdbFile, outfeatureClassName)))
                {
                    Console.WriteLine("Merge失败");
                    continue;
                }

                IFeatureClass featureClassA = workspaceA.GetFeatureClass(table.Name);

                IDataset datasetA = featureClassA as IDataset;

                datasetA.Delete();


                IFeatureClass featureClassAC = workspaceA.GetFeatureClass(outfeatureClassName);
                if (featureClassAC != null)
                {
                    IDataset datasetAc = featureClassAC as IDataset;
                    try
                    {
                        if (datasetAc.CanRename())
                        {
                            datasetAc.Rename(table.Name);
                        }
                    }
                    catch
                    {
                        Console.WriteLine("重命名失败");
                    }
                }
                Marshal.ReleaseComObject(featureClassA);
            }

            Marshal.ReleaseComObject(workspaceA);
            Marshal.ReleaseComObject(workspaceB);
        }
Exemplo n.º 23
0
 private static void deleteFeatureClass(IDataset ds)
 {
     if (ds.CanDelete())
     {
         try
         {
             ds.Delete();
         }
         catch (System.Runtime.InteropServices.COMException ex)
         {
             throw new System.IO.IOException(ex.Message + " " + System.IO.Path.Combine(((IWorkspace)ds).PathName, ds.Name));
         }
     }
 }
Exemplo n.º 24
0
 public void Delete()
 {
     try
     {
         IDataset o = this.Dataset;
         o.Delete();
         this.Detach();
         Marshal.ReleaseComObject(o);
         o = null;
     }
     catch
     {
     }
 }
        /// <summary>
        /// 矢量转栅格
        /// </summary>
        /// <param name="IFeatureClass">要转换的矢量数据</param>
        /// <param name="eleField">转换的字段名</param>
        /// <param name="cellsize">栅格大小,默认为null</param>
        ///<param name="rasterSavePath">保存路径</param>
        ///<param name="demName">dem名称</param>
        /// <returns>返回ILayer类型的图层</returns>
        public ILayer FeatureToRaster(IFeatureClass pFeatureClass, string eleField, object cellSize, string rasterSavePath, string demName)
        {
            IFeatureClassDescriptor pFeatureClassDescriptor = new FeatureClassDescriptorClass(); //获取转化的字段

            pFeatureClassDescriptor.Create(pFeatureClass, null, eleField);                       //转换字段
            IGeoDataset pGeoDataset = (IGeoDataset)pFeatureClassDescriptor;                      //获取第一个参数

            //默认栅格大小
            if (Convert.ToDouble(cellSize) <= 0)
            {
                IEnvelope envelope = pGeoDataset.Extent;
                if (envelope.Width > envelope.Height)
                {
                    cellSize = envelope.Height / 250;
                }
                else
                {
                    cellSize = envelope.Width / 250;
                }
            }
            IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactoryClass();
            IRasterWorkspace2 rasterWorkspace2 = workspaceFactory.OpenFromFile(rasterSavePath, 0) as IRasterWorkspace2;

            //in case that there is already an existing raster with the raster name, try to delete it
            if (System.IO.Directory.Exists(System.IO.Path.Combine(rasterSavePath, demName)))
            {
                IDataset dataset = rasterWorkspace2.OpenRasterDataset(demName) as IDataset;
                dataset.Delete();
            }
            IConversionOp conversionOp = new RasterConversionOpClass();
            IRasterAnalysisEnvironment rasterAnalysisEnvironment = conversionOp as IRasterAnalysisEnvironment;

            rasterAnalysisEnvironment.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref cellSize);
            IRasterDataset rasterDataset = null;

            try
            { rasterDataset = conversionOp.ToRasterDataset(pGeoDataset, "TIFF", (IWorkspace)rasterWorkspace2, demName); }
            catch (Exception ee)
            { MessageBox.Show(ee.Message); }
            ILayer layer = null;

            if (rasterDataset != null)
            {
                IRasterLayer pRlyr = new RasterLayerClass();
                pRlyr.CreateFromDataset(rasterDataset);
                layer = pRlyr as ILayer;
            }
            return(layer);
        }
Exemplo n.º 26
0
 //删除已存在的特征文件
 private void DelFeatFile(string sPath, string sName)
 {
     try
     {
         IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
         IFeatureWorkspace pFeatWorkspace    = pWorkspaceFactory.OpenFromFile(sPath, 0) as IFeatureWorkspace;
         IFeatureClass     pFeatCls          = pFeatWorkspace.OpenFeatureClass(sName);
         IDataset          pDataset          = pFeatCls as IDataset;
         pDataset.Delete();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 27
0
        }//获取夹角的辅助

        private void Save(string outfileNamePath)
        {
            //打开工作空间
            int    index  = outfileNamePath.LastIndexOf('\\');
            string folder = outfileNamePath.Substring(0, index);

            SaveFullName = outfileNamePath.Substring(index + 1);
            IWorkspaceFactory pWSF = new ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace pFWS = (IFeatureWorkspace)pWSF.OpenFromFile(folder, 0);


            if (File.Exists(outfileNamePath))
            {
                IFeatureClass featureClass = pFWS.OpenFeatureClass(SaveFullName);
                IDataset      pDataset     = (IDataset)featureClass;
                pDataset.Delete();
            }


            IFields     pFields = new FieldsClass();
            IFieldsEdit pFieldsEdit;

            pFieldsEdit = (IFieldsEdit)pFields;
            IField     pField     = new FieldClass();
            IFieldEdit pFieldEdit = (IFieldEdit)pField;

            pFieldEdit.Name_2 = "Shape";
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            //空间参考
            IGeometryDef     pGeometryDef = new GeometryDefClass();
            IGeometryDefEdit pGDefEdit    = (IGeometryDefEdit)pGeometryDef;

            pGDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolyline;
            pFieldEdit.GeometryDef_2 = pGeometryDef;
            pFieldsEdit.AddField(pField);

            IFeatureClass pFeatureClass;

            pFeatureClass = pFWS.CreateFeatureClass(SaveFullName, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
            pGeometryList = this.GetGeometry(roadDataFullName);
            pGeoSave      = strokeIt(pGeometryList);
            for (int i = 0; i < pGeoSave.Count; i++)
            {
                IFeature pFeature = pFeatureClass.CreateFeature();
                pFeature.Shape = pGeoSave[i];
                pFeature.Store();
            }
        }
Exemplo n.º 28
0
        /// <summary>
        ///     Deletes the table. You must have exlusive rights to the table in order to delete it.
        ///     Otherwise an error will be thrown.
        /// </summary>
        public static void Delete(this ITable source)
        {
            IDataset    ds         = (IDataset)source;
            ISchemaLock schemaLock = (ISchemaLock)ds;

            try
            {
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

                ds.Delete();
            }
            finally
            {
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
        }
Exemplo n.º 29
0
        //根据配置文件初始化系统环境 added by chulili 20110531
        public static void InitSystemByXML(IWorkspace sourceWorkspace, IWorkspace targetWorkspace, bool iscover)
        {
            //xml模板位置固定,根据模板中规定的表名进行拷贝
            string      xmlpath = Application.StartupPath + "\\..\\Template\\InitUserRoleConfig.Xml";
            XmlDocument doc     = new XmlDocument();

            doc.Load(xmlpath);
            string      strSearch       = "//InitSystemRoot";
            XmlNode     pInitSystemnode = doc.SelectSingleNode(strSearch);
            XmlNodeList pInitSystemlist = pInitSystemnode.ChildNodes;

            //遍历需要拷贝的表名
            foreach (XmlNode pnode in pInitSystemlist)
            {
                if (pnode.NodeType == XmlNodeType.Element)
                {
                    XmlElement pEle         = pnode as XmlElement;
                    string     strTableName = pEle.GetAttribute("Name");
                    if (iscover)//如果覆盖,则先把目标库中该表删除
                    {
                        try
                        {
                            IFeatureWorkspace ptmpwks             = targetWorkspace as IFeatureWorkspace;
                            ESRI.ArcGIS.Geodatabase.ITable ptable = ptmpwks.OpenTable(strTableName);
                            IDataset pdataset = ptable as IDataset;
                            pdataset.Delete();
                        }
                        catch (Exception e)
                        {
                        }
                        CopyPasteGDBData.CopyPasteGeodatabaseData(sourceWorkspace, targetWorkspace, strTableName, esriDatasetType.esriDTTable);
                    }
                    else
                    {
                        try//如果不覆盖,判断该表是否存在,不存在则拷贝表
                        {
                            IFeatureWorkspace ptmpwks = targetWorkspace as IFeatureWorkspace;
                            ptmpwks.OpenTable(strTableName);
                        }
                        catch (Exception e)
                        {
                            CopyPasteGDBData.CopyPasteGeodatabaseData(sourceWorkspace, targetWorkspace, strTableName, esriDatasetType.esriDTTable);
                        }
                    }
                }
            }
        }
Exemplo n.º 30
0
        internal IFeatureClass RasterToPolygon(IRaster inputRaster, string outputName, string outputDir, bool smoothShapes)
        {
            IWorkspace    workspace    = SetupOp.OpenShapeFileWorkspace(outputDir);
            IConversionOp conversionOp = new RasterConversionOpClass();

            try
            {
                IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;

                //Delete any existing
                IEnumDatasetName datasets = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
                datasets.Reset();
                IDataset     existing    = null;
                IDatasetName datasetName = datasets.Next();
                while (datasetName != null)
                {
                    if (string.Compare(outputName, datasetName.Name, true) == 0)
                    {
                        existing = (IDataset)((IName)datasetName).Open();
                        break;
                    }
                    datasetName = datasets.Next();
                }
                if (existing != null)
                {
                    try
                    {
                        existing.Delete();
                    }
                    finally
                    {
                        UrbanDelineationExtension.ReleaseComObject(existing);
                    }
                }

                //Convert to polygon feature
                SetAnalysisEnvironment((IRasterAnalysisEnvironment)conversionOp);
                IGeoDataset polygons = conversionOp.RasterDataToPolygonFeatureData((IGeoDataset)inputRaster, workspace, outputName, smoothShapes);
                return((IFeatureClass)polygons);
            }
            finally
            {
                UrbanDelineationExtension.ReleaseComObject(workspace);
                UrbanDelineationExtension.ReleaseComObject(conversionOp);
            }
        }
Exemplo n.º 31
0
 public void Delete()
 {
     try
     {
         IDataset dataset = this.Dataset;
         if (dataset != null)
         {
             dataset.Delete();
             dataset = null;
             this.igxCatalog_0.ObjectDeleted(this);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
Exemplo n.º 32
0
        void IFeatureClassManager.DeleteFeatureClass(IDataset data)
        {
            using (ComReleaser releaser = new ComReleaser())
               {
               _workspaceEdit = (IWorkspaceEdit)_workspace;
               _mWorkspaceEdit = (IMultiuserWorkspaceEdit)_workspace;
               //releaser.ManageLifetime(_workspaceEdit);
               //releaser.ManageLifetime(_mWorkspaceEdit);

               _mWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
               _workspaceEdit.StartEditOperation();

               try
               {
                   data.Delete();
                   _workspaceEdit.StartEditOperation();
                   _workspaceEdit.StopEditing(true);
               }
               catch (Exception ex)
               {
                   _workspaceEdit.AbortEditOperation();
                   _workspaceEdit.StopEditing(false);
               }

               }
               //fcThuaCliped = fw.OpenFeatureClass("thua_sau50m_clip");
               //IDataset ft = (IDataset)fcThuaCliped;
        }
Exemplo n.º 33
0
        /// <summary>
        /// Deletes the dataset if possible
        /// </summary>
        /// <remarks>
        /// - Checks for a shcema lock before deleting (CanDelete returns true even if the dataset is locked)
        /// - Returns true if the dataset was deleted, else false
        /// </remarks>
        private static bool DeleteDataset(IDataset ds)
        {
            ISchemaLock schemaLock = ds as ISchemaLock;

            if (ds.CanDelete() && (schemaLock != null))
            {
                try
                {
                    schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                    ds.Delete();
                    return true;
                }
                catch
                {
                    schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
                }
            }

            return false;
        }