Esempio n. 1
0
        private void deleteFeatureClassToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IDataSource     ds   = null;
            IFeatureDataSet dset = null;

            try
            {
                myTreeNode      node = (myTreeNode)selectNode.Parent.Parent;
                IConnectionInfo ci   = node.con;
                ds   = dsFactory.OpenDataSource(ci);
                dset = ds.OpenFeatureDataset(selectNode.Parent.Text);

                if (MessageBox.Show("该操作无法恢复,请确定是否删除要素类?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    String fcname = selectNode.Text;
                    if (dset.DeleteByName(fcname))
                    {
                        selectNode.Parent.Nodes.Remove(selectNode);
                    }
                    else
                    {
                        MessageBox.Show("删除失败");
                    }
                }
            }
            catch (COMException comEx)
            {
                System.Diagnostics.Trace.WriteLine(comEx.Message);
            }
            catch (System.Exception ex)
            {
                if (ex.Source == "物理数据源不存在")
                {
                    this.treeView1.Nodes.Remove(selectNode.Parent.Parent);
                    MessageBox.Show(ex.Source);
                }
                else
                {
                    MessageBox.Show("删除失败");
                }

                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                if (dset != null)
                {
                    //Marshal.ReleaseComObject(dset);
                    dset = null;
                }
                if (ds != null)
                {
                    //Marshal.ReleaseComObject(ds);
                    ds = null;
                }
            }
        }
Esempio n. 2
0
        private void deleteDataSetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IDataSource     ds   = null;
            IFeatureDataSet dset = null;

            try
            {
                if (MessageBox.Show("该操作无法恢复,请确定是否删除数据集?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    myTreeNode      node = (myTreeNode)selectNode.Parent;
                    IConnectionInfo ci   = node.con;
                    ds   = dsFactory.OpenDataSource(ci);
                    dset = ds.OpenFeatureDataset(selectNode.Text);

                    Array tem = dset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                    if (tem != null)
                    {
                        foreach (String strFC in tem)
                        {
                            IFeatureClass fc = dset.OpenFeatureClass(strFC);
                            dset.DeleteByName(strFC);
                            //Marshal.ReleaseComObject(fc);
                            fc = null;
                        }
                    }
                    ds.DeleteFeatureDataset(selectNode.Text);

                    // 从普通表里删除dataset对应的记录
                    DeleteLogicTree(ds, selectNode.Text);

                    // 从树上删节点
                    node.Nodes.Remove(selectNode);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                if (ds != null)
                {
                    //Marshal.ReleaseComObject(ds);
                    ds = null;
                }
                if (dset != null)
                {
                    //Marshal.ReleaseComObject(dset);
                    dset = null;
                }
            }
        }
Esempio n. 3
0
 private bool DeleteFeatureClass(string dataSetName, string fcName)
 {
     try
     {
         IFeatureDataSet fds = this._dsPipe.OpenFeatureDataset(dataSetName);
         if (fds == null)
         {
             return(false);
         }
         return(fds.DeleteByName(fcName));
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 4
0
        private void SyncTopoInfo()
        {
            try
            {
                IFeatureDataSet fds = this._dsPipe.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return;
                }

                List <TopoClass> allTC = GetAllTopoClasses();
                if (allTC == null || allTC.Count == 0)
                {
                    return;
                }

                #region 检查删除管线库中的拓扑信息表,有就不删,没有就删除
                WaitForm.SetCaption("检查管线库中的拓扑信息表...");
                string[] namesByType = fds.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (namesByType == null)
                {
                    return;
                }
                foreach (string str in namesByType)
                {
                    if (str.ToUpper().IndexOf("TOPO_OC_") == 0)
                    {
                        bool flag = true;
                        if ((allTC == null) || (allTC.Count == 0))
                        {
                            flag = true;
                        }
                        else
                        {
                            foreach (TopoClass tc in allTC)
                            {
                                if (tc.TopoTable == str)
                                {
                                    flag = false;
                                    break;
                                }
                            }
                        }
                        if (flag)
                        {
                            fds.DeleteByName(str);
                        }
                    }
                }
                #endregion

                #region 创建拓扑信息表
                WaitForm.SetCaption("创建管线库中的拓扑信息表...");
                foreach (TopoClass tc in allTC)
                {
                    string topoTableName = tc.TopoTable;
                    if (Array.IndexOf <string>(namesByType, topoTableName) == -1)
                    {
                        string[]      arrDBIndex = null;
                        IFeatureClass fc         = fds.CreateFeatureClass(topoTableName, GetTopoInfoFields(out arrDBIndex));
                        if (fc != null)
                        {
                            fc.AliasName = tc.Name + "拓扑信息表";
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("同步管线库中的拓扑信息表失败!", "提示");
            }
        }