예제 #1
0
        private DF3DPipeCreateApp()
        {
            try
            {
                IConnectionInfo connInfo1 = new ConnectionInfo();
                connInfo1.FromConnectionString(Config.GetConfigValue("3DTemplateDataConnStr"));
                IDataSourceFactory dsf1 = new DataSourceFactory();
                if (dsf1.HasDataSource(connInfo1))
                {
                    this._TemplateLib = dsf1.OpenDataSource(connInfo1);
                }

                IConnectionInfo connInfo2 = new ConnectionInfo();
                connInfo2.FromConnectionString(Config.GetConfigValue("3DPipeDataConnStr"));
                IDataSourceFactory dsf2 = new DataSourceFactory();
                if (dsf2.HasDataSource(connInfo2))
                {
                    this._PipeLib = dsf2.OpenDataSource(connInfo2);
                }

                IConnectionInfo connInfo3 = new ConnectionInfo();
                connInfo3.FromConnectionString(Config.GetConfigValue("3DTempDataConnStr"));
                IDataSourceFactory dsf3 = new DataSourceFactory();
                if (dsf3.HasDataSource(connInfo3))
                {
                    this._TempLib = dsf3.OpenDataSource(connInfo3);
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #2
0
 public static bool CanConnection(IConnectionInfo connInfo)
 {
     try
     {
         IDataSourceFactory dsf = new DataSourceFactory();
         return(dsf.HasDataSource(connInfo));
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
예제 #3
0
        public static Dictionary <string, IFeatureClass> GetFeatureClass(IConnectionInfo ci)
        {
            try
            {
                Dictionary <string, IFeatureClass> fcs = new Dictionary <string, IFeatureClass>();
                IDataSourceFactory dsFactory           = new DataSourceFactory();
                if (!dsFactory.HasDataSource(ci))
                {
                    return(null);
                }
                IDataSource ds = dsFactory.OpenDataSource(ci);
                if (ds == null)
                {
                    return(null);
                }
                string[] setnames = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return(null);
                }
                for (int j = 0; j < setnames.Length; j++)
                {
                    IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[j]);

                    string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                    if (fcnames.Length == 0)
                    {
                        continue;
                    }
                    foreach (string name in fcnames)
                    {
                        IFeatureClass fc = dataset.OpenFeatureClass(name);
                        if (fc == null)
                        {
                            continue;
                        }
                        fcs[fc.GuidString] = fc;
                    }
                }
                return(fcs);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #4
0
        public static void Add3DPlanData(IConnectionInfo ci, Layer3DPlanTreePad pad, TreeList parentTree)
        {
            try
            {
                if (ci == null || parentTree == null)
                {
                    return;
                }
                DF3DApplication app = DF3DApplication.Application;
                if (app == null || app.Current3DMapControl == null)
                {
                    return;
                }
                //AxRenderControl d3 = app.Current3DMapControl;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                if (!dsFactory.HasDataSource(ci))
                {
                    return;
                }
                IDataSource ds = dsFactory.OpenDataSource(ci);
                if (ds == null)
                {
                    return;
                }
                List <Plan>           allPlan = SelectPlans(ds, "1=1");
                Dictionary <int, int> planIds = new Dictionary <int, int>();
                if ((allPlan != null) && (allPlan.Count > 0))
                {
                    for (int i = 0; i < allPlan.Count; i++)
                    {
                        planIds.Add(allPlan[i].PlanID, (int)allPlan[i].ConnType);
                    }
                }

                //**********加权限 控制可见性 修改**********

                //****************************************
                InitTree(pad, parentTree, ds, allPlan, planIds);
            }
            catch (Exception ex)
            {
            }
        }
예제 #5
0
 private void OpenTemplateLib()
 {
     try
     {
         IConnectionInfo connInfo = new ConnectionInfo();
         connInfo.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
         connInfo.Database       = this.buttonEditFilePath.Text.ToString().Trim();
         connInfo.Password       = this.tePwd.Text;
         IDataSourceFactory dsf = new DataSourceFactory();
         if (dsf.HasDataSource(connInfo))
         {
             if (DF3DPipeCreateApp.App.TemplateLib != null)
             {
                 DF3DPipeCreateApp.App.TemplateLib.Close();
                 System.Runtime.InteropServices.Marshal.ReleaseComObject(DF3DPipeCreateApp.App.TemplateLib);
                 DF3DPipeCreateApp.App.TemplateLib = null;
             }
             DF3DPipeCreateApp.App.TemplateLib = dsf.OpenDataSource(connInfo);
             if (DF3DPipeCreateApp.App.TemplateLib != null)
             {
                 XtraMessageBox.Show("设置成功!", "提示");
                 Config.SetConfigValue("3DTemplateDataConnStr", connInfo.ToConnectionString());
             }
             else
             {
                 XtraMessageBox.Show("设置失败!", "提示");
             }
         }
         else
         {
             XtraMessageBox.Show("数据连接失败!", "提示");
             return;
         }
     }
     catch (Exception ex)
     {
     }
 }
예제 #6
0
        public static void AddAndVisualizeBaseData(IConnectionInfo ci, string geoColumnName, TreeList parentTree, bool bNeedFly = false, bool bTempData = true)
        {
            try
            {
                if (ci == null || parentTree == null)
                {
                    return;
                }
                if (bTempData)
                {
                    WaitForm.Start("正在加载三维数据,请稍后...", "提示");
                }

                DF3DApplication app = DF3DApplication.Application;
                if (app == null || app.Current3DMapControl == null)
                {
                    return;
                }
                AxRenderControl    d3        = app.Current3DMapControl;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                if (!dsFactory.HasDataSource(ci))
                {
                    return;
                }
                IDataSource ds = dsFactory.OpenDataSource(ci);
                if (ds == null)
                {
                    return;
                }
                //TreeNodeDatabase tnDatabase = new TreeNodeDatabase()
                //{
                //    Name = ci.ConnectionType == gviConnectionType.gviConnectionFireBird2x ? System.IO.Path.GetFileNameWithoutExtension(ci.Database) : ci.Database,
                //    CustomValue = ds,
                //    Temp = bTempData
                //};
                //tnDatabase.OwnNode = parentTree.AppendNode(new object[] { tnDatabase.Name }, (TreeListNode)null);
                //tnDatabase.Visible = true;

                string[] setnames = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                for (int j = 0; j < setnames.Length; j++)
                {
                    IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[j]);

                    string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                    if (fcnames.Length == 0)
                    {
                        continue;
                    }

                    TreeNodeDataset tnDataset = new TreeNodeDataset()
                    {
                        Name        = dataset.Alias,
                        CustomValue = dataset,
                        Temp        = bTempData
                    };
                    tnDataset.OwnNode = parentTree.AppendNode(new object[] { tnDataset.Name }, (TreeListNode)null);
                    //tnDatabase.Add(tnDataset);

                    foreach (string name in fcnames)
                    {
                        IFeatureClass fc = dataset.OpenFeatureClass(name);
                        if (fc == null)
                        {
                            continue;
                        }
                        TreeNodeFeatureClass tnFeatureClass = new TreeNodeFeatureClass(fc.GuidString)
                        {
                            Name        = fc.AliasName,
                            CustomValue = fc,
                            Temp        = bTempData
                        };
                        tnDataset.Add(tnFeatureClass);

                        IFieldInfoCollection fieldinfos = fc.GetFields();
                        if (fieldinfos == null)
                        {
                            continue;
                        }
                        int index = fieldinfos.IndexOf(geoColumnName);
                        if (index == -1)
                        {
                        }
                        else
                        {
                            IFieldInfo fieldinfo = fieldinfos.Get(index);
                            if (null == fieldinfo)
                            {
                                continue;
                            }
                            IGeometryDef  geometryDef = fieldinfo.GeometryDef;
                            IFeatureLayer fl          = null;
                            if (null != geometryDef)
                            {
                                fl = d3.ObjectManager.CreateFeatureLayer(fc, fieldinfo.Name, null, null, d3.ProjectTree.RootID);
                                tnFeatureClass.SetVisualFeatureLayer(fl);
                                switch (geometryDef.GeometryColumnType)
                                {
                                case gviGeometryColumnType.gviGeometryColumnModelPoint:
                                    tnFeatureClass.Visible    = true;
                                    tnFeatureClass.ImageIndex = 3;
                                    break;

                                case gviGeometryColumnType.gviGeometryColumnPOI:
                                case gviGeometryColumnType.gviGeometryColumnPoint:
                                    tnFeatureClass.Visible    = false;
                                    tnFeatureClass.ImageIndex = 4;
                                    break;

                                case gviGeometryColumnType.gviGeometryColumnPolyline:
                                    tnFeatureClass.Visible    = false;
                                    tnFeatureClass.ImageIndex = 5;
                                    break;

                                case gviGeometryColumnType.gviGeometryColumnPolygon:
                                    tnFeatureClass.Visible    = false;
                                    tnFeatureClass.ImageIndex = 6;
                                    break;
                                }
                            }

                            // 加入管理类
                            if (!bTempData && fl != null)
                            {
                                DF3DFeatureClass dfFC = new DF3DFeatureClass(fc);
                                dfFC.SetFeatureLayer(fl);
                                dfFC.SetTreeLayer(tnFeatureClass);
                                Render3D.Instance.SetRender(tnFeatureClass, dfFC);
                                DF3DFeatureClassManager.Instance.Add(dfFC);
                            }


                            if (fl != null && bNeedFly)
                            {
                                IEulerAngle angle = new EulerAngle();
                                angle.Set(0, -20, 0);
                                d3.Camera.SetCamera(fl.Envelope.Center, angle, gviSetCameraFlags.gviSetCameraNoFlags);
                                bNeedFly = false;
                            }
                        }
                    }
                    tnDataset.CollapseAll();
                }
                //tnDatabase.CollapseAll();

                //ds.Close();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("加载三维数据失败,请检查数据是否被占用或链接是否有错误。", "提示");
                LoggingService.Error("加载三维数据失败:" + ex.Message);
            }
            finally
            {
                if (bTempData)
                {
                    WaitForm.Stop();
                }
            }
        }
예제 #7
0
        public static Dictionary <string, IRowBuffer> GetPipeInfos(IConnectionInfo ci, string datasetName, string ocName)
        {
            Dictionary <string, IRowBuffer> infos = new Dictionary <string, IRowBuffer>();
            IFdeCursor   o      = null;
            IQueryFilter filter = null;
            IRowBuffer   r      = null;

            try
            {
                IDataSourceFactory dsFactory = new DataSourceFactory();
                if (!dsFactory.HasDataSource(ci))
                {
                    return(null);
                }
                IDataSource ds = dsFactory.OpenDataSource(ci);
                if (ds == null)
                {
                    return(null);
                }
                string[] setnames = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return(null);
                }
                for (int i = 0; i < setnames.Length; i++)
                {
                    if (setnames[i] != datasetName)
                    {
                        continue;
                    }
                    IFeatureDataSet fds = ds.OpenFeatureDataset(setnames[i]);
                    IObjectClass    oc  = fds.OpenObjectClass(ocName);
                    if (oc == null)
                    {
                        return(null);
                    }
                    filter = new QueryFilterClass
                    {
                        WhereClause = ""
                    };
                    o = oc.Search(filter, false);
                    while ((r = o.NextRow()) != null)
                    {
                        string code = r.GetValue(r.FieldIndex("Code")).ToString();
                        infos[code] = r;
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (filter != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(filter);
                    filter = null;
                }
                if (o != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
                    o = null;
                }
                if (r != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(r);
                    r = null;
                }
            }
            return(infos);
        }
예제 #8
0
 private void LoadData(IConnectionInfo connInfo)
 {
     try
     {
         IDataSourceFactory dsFactory = new DataSourceFactory();
         if (dsFactory.HasDataSource(connInfo))
         {
             IDataSource ds = dsFactory.OpenDataSource(connInfo);
             if (ds != null)
             {
                 string[] strfdss = ds.GetFeatureDatasetNames();
                 if (strfdss == null)
                 {
                     return;
                 }
                 foreach (string strfds in strfdss)
                 {
                     IFeatureDataSet fds = ds.OpenFeatureDataset(strfds);
                     if (fds == null)
                     {
                         continue;
                     }
                     string[] fcnames = fds.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                     if (fcnames == null)
                     {
                         continue;
                     }
                     foreach (string fcname in fcnames)
                     {
                         IFeatureClass fc = fds.OpenFeatureClass(fcname);
                         if (fc == null)
                         {
                             continue;
                         }
                         DataRow dr = this._dt.NewRow();
                         dr["FeatureClassAlias"] = fc.AliasName;
                         dr["FeatureClassName"]  = fc.Name;
                         dr["FeatureClass"]      = fc;
                         dr["CheckState"]        = true;
                         FacilityClass facC = DF3DData.Class.Dictionary3DTable.Instance.GetFacilityClassByDFFeatureClassID(fc.Guid.ToString());
                         if (facC != null)
                         {
                             dr["FacilityClass"] = facC;
                         }
                         else
                         {
                             foreach (FacilityClass facTemp in FacilityClassManager.Instance.GetAllFacilityClass())
                             {
                                 if (fc.AliasName.Contains(facTemp.Alias))
                                 {
                                     dr["FacilityClass"] = facTemp;
                                     break;
                                 }
                             }
                         }
                         MajorClass mc = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(fc.Guid.ToString());
                         if (mc != null)
                         {
                             dr["MajorClass"] = mc;
                         }
                         else
                         {
                             foreach (MajorClass mcTemp in LogicDataStructureManage3D.Instance.GetAllMajorClass())
                             {
                                 if (fc.AliasName.Contains(mcTemp.Alias))
                                 {
                                     dr["MajorClass"] = mcTemp;
                                     break;
                                 }
                             }
                         }
                         this._dt.Rows.Add(dr);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
 }