示例#1
0
        public int GetMaxOID(IFeatureClass fc)
        {
            int maxOID = -1;

            if (fc == null)
            {
                return(maxOID);
            }
            QueryFilter filter = new QueryFilter();

            filter.AddSubField("max(oid) as MaxID");
            IFdeCursor cur = fc.Search(filter, true);
            IRowBuffer row = cur.NextRow();

            //Marshal.ReleaseComObject(cur);
            if (row == null)
            {
                return(maxOID);
            }

            if (row.IsNull(0))
            {
                return(maxOID);
            }

            maxOID = int.Parse(row.GetValue(0).ToString());

            return(maxOID);
        }
示例#2
0
        public void InsertFeatures(IObjectClass oc, IRowBufferCollection rows)
        {
            if (oc == null || rows == null || rows.Count == 0)
            {
                return;
            }
            IFdeCursor cursor = null;

            try
            {
                oc.FeatureDataSet.DataSource.StartEditing();
                cursor = oc.Insert();
                for (int i = 0; i < rows.Count; ++i)
                {
                    IRowBuffer row = rows.Get(i);
                    cursor.InsertRow(row);
                    int oid = cursor.LastInsertId;
                    row.SetValue(0, oid);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                if (cursor != null)
                {
                    //Marshal.ReleaseComObject(cursor);
                    oc.FeatureDataSet.DataSource.StopEditing(true);
                }
                //Marshal.ReleaseComObject(cursor);
            }
        }
示例#3
0
        public System.Collections.ArrayList GetCollectionofField(ITable table, string field)
        {
            IFdeCursor fdeCursor = null;

            System.Collections.ArrayList arrayList = new System.Collections.ArrayList();
            System.Collections.ArrayList result;
            try
            {
                IQueryFilter queryFilter = new QueryFilterClass();
                queryFilter.AddSubField(field);
                queryFilter.WhereClause = "1=1";
                fdeCursor = table.Search(queryFilter, false);
                IRowBuffer rowBuffer;
                while ((rowBuffer = fdeCursor.NextRow()) != null)
                {
                    int    position = rowBuffer.FieldIndex("name");
                    string value    = rowBuffer.GetValue(position).ToString();
                    arrayList.Add(value);
                }
                result = arrayList;
            }
            catch (System.Exception)
            {
                result = arrayList;
            }
            finally
            {
                if (fdeCursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                    fdeCursor = null;
                }
            }
            return(result);
        }
示例#4
0
        private byte[] GetLogicTreeContent(IFeatureDataSet dataset)
        {
            byte[] strContent = null;

            try
            {
                IQueryDef qd = dataset.DataSource.CreateQueryDef();
                qd.AddSubField("content");

                qd.Tables      = new String[] { "cm_logictree", "cm_group" };
                qd.WhereClause = String.Format("cm_group.groupuid = cm_logictree.groupid "
                                               + " and cm_group.DataSet = '{0}'", dataset.Name);

                IFdeCursor cursor = qd.Execute(false);
                IRowBuffer row    = null;
                if ((row = cursor.NextRow()) != null)
                {
                    //content
                    int nPose = row.FieldIndex("content");
                    if (nPose != -1)
                    {
                        IBinaryBuffer bb = row.GetValue(nPose) as IBinaryBuffer;
                        strContent = (byte[])bb.AsByteArray();
                    }
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return(null);
            }

            return(strContent);
        }
示例#5
0
        public bool GetQueryResults(string whereclause, string tablename, IDataSource ds)
        {
            ITable      table       = null;
            QueryFilter queryFilter = null;
            IFdeCursor  fdeCursor   = null;
            bool        result;

            try
            {
                table       = ds.OpenTable(tablename);
                queryFilter = new QueryFilterClass();
                if (whereclause == null)
                {
                    queryFilter.WhereClause = "1=1";
                }
                else
                {
                    queryFilter.WhereClause = whereclause;
                }
                fdeCursor = table.Search(queryFilter, true);
                if (fdeCursor.NextRow() != null)
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                LoggingService.Error(ex.Message + "\r\n" + ex.StackTrace);
                throw;
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                if (fdeCursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                    fdeCursor = null;
                }
                if (queryFilter != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(queryFilter);
                    queryFilter = null;
                }
                if (table != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(table);
                    table = null;
                }
            }
            return(result);
        }
示例#6
0
        private bool UpdateFacClassReg(FacClassReg reg)
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IFeatureDataSet fds = this._dsPipe.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(false);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_FacilityClass");
                if (oc == null)
                {
                    return(false);
                }

                IQueryFilter filter = new QueryFilter()
                {
                    WhereClause = string.Format("FacClassCode = '{0}'", reg.FacClassCode),
                    SubFields   = "oid,LocationType,TurnerStyle,FacilityType,Comment"
                };
                cursor = oc.Update(filter);
                row    = cursor.NextRow();
                if (row != null)
                {
                    row.SetValue(1, reg.LocationType.ToString());
                    row.SetValue(2, reg.TurnerStyle.ToString());
                    row.SetValue(3, reg.FacilityType.Name);
                    row.SetValue(4, reg.Comment);
                    cursor.UpdateRow(row);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
示例#7
0
文件: MainForm.cs 项目: batuZ/Samples
        private bool CreateLCRecordOfFDS(IDataSource ds, String fdsname)
        {
            ITable     table  = null;
            IFdeCursor cursor = null;

            try
            {
                String lcguid = System.Guid.NewGuid().ToString();
                byte[] lcbuf  = CreateLogicTree("LogicTree", lcguid);

                if (!GetQueryResults(String.Format("groupid='{0}'", lcguid), "cm_logictree", ds))
                {
                    table  = ds.OpenTable("cm_logictree");
                    cursor = table.Insert();
                    RowBufferFactory rbf = new RowBufferFactory();
                    IRowBuffer       rb  = rbf.CreateRowBuffer(table.GetFields());
                    rb.SetValue(1, lcguid);  //groupid
                    rb.SetValue(2, fdsname); //name
                    rb.SetValue(3, fdsname); //founder
                    IBinaryBuffer bb = new BinaryBuffer();
                    bb.FromByteArray(lcbuf);
                    rb.SetValue(4, bb);   //content
                    cursor.InsertRow(rb);
                }
                table  = ds.OpenTable("cm_group");
                cursor = table.Insert();
                RowBufferFactory rbf1 = new RowBufferFactory();
                IRowBuffer       rb1  = rbf1.CreateRowBuffer(table.GetFields());
                rb1.SetValue(1, lcguid);  //groupuid
                rb1.SetValue(2, fdsname); //DataSet
                cursor.InsertRow(rb1);
                return(true);
            }
            catch (COMException comEx)
            {
                System.Diagnostics.Trace.WriteLine(comEx.Message);
                return(false);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return(false);
            }
            finally
            {
                if (cursor != null)
                {
                    //Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (table != null)
                {
                    //Marshal.ReleaseComObject(table);
                    table = null;
                }
            }
        }
示例#8
0
文件: MainForm.cs 项目: batuZ/Samples
        /// <summary>
        /// 返回table查询记录,返回0条为false,大于0条为true
        /// </summary>
        /// <param name="whereclause">查询条件字符串</param>
        /// <param name="tablename">查询的表名</param>
        /// <param name="fds">查询的数据集</param>
        /// <returns></returns>
        public bool GetQueryResults(String whereclause, String tablename, IDataSource ds)
        {
            ITable      table  = null;
            QueryFilter filter = null;
            IFdeCursor  cursor = null;

            try
            {
                table  = ds.OpenTable(tablename);
                filter = new QueryFilter();
                if (whereclause == null)
                {
                    filter.WhereClause = "1=1";
                }
                else
                {
                    filter.WhereClause = whereclause;
                }
                cursor = table.Search(filter, true);
                if (cursor.NextRow() != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (COMException comEx)
            {
                System.Diagnostics.Trace.WriteLine(comEx.Message);
                throw;
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                throw;
            }
            finally
            {
                if (cursor != null)
                {
                    //Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (filter != null)
                {
                    //Marshal.ReleaseComObject(filter);
                    filter = null;
                }
                if (table != null)
                {
                    //Marshal.ReleaseComObject(table);
                    table = null;
                }
            }
        }
        public static TopoClass GetTopoClassByFacClassCode(string facClassCode)
        {
            if (DF3DPipeCreateApp.App.TemplateLib == null)
            {
                return(null);
            }
            IFdeCursor   o      = null;
            IRowBuffer   buffer = null;
            IQueryFilter filter = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_Catalog");
                if (oc == null)
                {
                    return(null);
                }
                filter = new QueryFilterClass
                {
                    WhereClause = string.Format("Code = '{0}'", facClassCode),
                    SubFields   = "TopoLayerId"
                };
                o      = oc.Search(filter, true);
                buffer = o.NextRow();
                if (buffer != null)
                {
                    if (buffer.IsNull(0))
                    {
                        return(null);
                    }
                    return(FacilityInfoService.GetTopoClassByObjectId(buffer.GetValue(0).ToString()));
                }
                return(null);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (o != null)
                {
                    Marshal.ReleaseComObject(o);
                    o = null;
                }
                if (buffer != null)
                {
                    Marshal.ReleaseComObject(buffer);
                    buffer = null;
                }
            }
        }
示例#10
0
        private void RectQuery()
        {
            IFdeCursor     cursor = null;
            IRowBuffer     row    = null;
            IGeometry      geo    = this._drawTool.GetGeo();
            ISpatialFilter filter = new SpatialFilter();

            filter.Geometry = geo;
        }
示例#11
0
文件: MainForm.cs 项目: batuZ/Samples
        void axRenderControl1_RcMouseClickSelect_CreateFeature(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            _geoEditor.FinishEdit();   //用于当拾取到基准面时,或者没有正常右键结束连续调用Start时
            this.axRenderControl1.FeatureManager.UnhighlightAll();

            if (PickResult != null)
            {
                switch (PickResult.Type)
                {
                case gviObjectType.gviObjectFeatureLayer:
                {
                    IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult;
                    int fid = flpr.FeatureId;
                    //加载多FeatureClass时要每次重新获取
                    _featureClass = (IFeatureClass)fcGUIDMap[flpr.FeatureLayer.FeatureClassId];
                    _featureLayer = flpr.FeatureLayer;

                    IFdeCursor cursor = null;
                    try
                    {
                        _buffer = _featureClass.CreateRowBuffer();
                        IQueryFilter filter = new QueryFilter();
                        //filter.AddSubField("oid");  //注意:StartEditFeatureGeometry里必须传入一个完整的rowbuffer,所以这里不能限定字段
                        filter.WhereClause = "oid =" + fid;
                        cursor             = _featureClass.Search(filter, false);
                        IRowBuffer row = null;

                        if ((row = cursor.NextRow()) != null)
                        {
                            _buffer = row as IRowBuffer;
                            int pos = _buffer.FieldIndex("Geometry");
                            oldfdeGeometry = _buffer.GetValue(pos) as IGeometry;
                            _buffer.SetValue(0, _featureClass.GetCount(null));          //修改fid为不同值,否则不是创建而是编辑
                        }
                    }
                    catch (COMException ex)
                    {
                        System.Diagnostics.Trace.WriteLine(ex.Message);
                    }
                    finally
                    {
                    }

                    this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow);

                    resultCode = _geoEditor.StartEditFeatureGeometry(_buffer, _featureLayer, gviGeoEditType.gviGeoEditCreator);
                    if (!resultCode)
                    {
                        MessageBox.Show(this.axRenderControl1.GetLastError().ToString());
                    }
                }
                break;
                }
            }
        }
示例#12
0
文件: MainForm.cs 项目: batuZ/Samples
 private void GetResultSet(IFeatureClass fc, IQueryFilter filter, DataTable dt)
 {
     if (fc != null)
     {
         IFdeCursor cursor = null;
         try
         {
             if (filter != null)
             {
                 filter.PostfixClause = "order by oid asc";
             }
             // 查找所有记录
             cursor = fc.Search(filter, true);
             if (cursor != null)
             {
                 dt.BeginLoadData();
                 IRowBuffer fdeRow = null;
                 DataRow    dr     = null;
                 while ((fdeRow = cursor.NextRow()) != null)
                 {
                     dr = dt.NewRow();
                     for (int i = 0; i < dt.Columns.Count; ++i)
                     {
                         string strColName = dt.Columns[i].ColumnName;
                         int    nPos       = fdeRow.FieldIndex(strColName);
                         if (nPos == -1 || fdeRow.IsNull(nPos))
                         {
                             continue;
                         }
                         object v = fdeRow.GetValue(nPos);  // 从库中读取值
                         dr[i] = v;
                     }
                     dt.Rows.Add(dr);
                 }
                 dt.EndLoadData();
             }
             // 通过解析逻辑树获取GroupId对应的GroupName
             GroupId2LayerName(dt, fc.FeatureDataSet);
         }
         catch (COMException ex)
         {
             System.Diagnostics.Trace.WriteLine(ex.Message);
         }
         finally
         {
             if (cursor != null)
             {
                 //Marshal.ReleaseComObject(cursor);
                 cursor = null;
             }
         }
     }
 }
示例#13
0
        private void SearchRes(IFeatureClass fc, string fieldName, string fieldValue)
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                int fidIndex = fc.GetFields().IndexOf(fc.FidFieldName);
                if (fidIndex == -1)
                {
                    return;
                }
                int nameIndex = fc.GetFields().IndexOf(fieldName);
                if (nameIndex == -1)
                {
                    return;
                }
                int geoIndex = fc.GetFields().IndexOf("Geometry");
                if (geoIndex == -1)
                {
                    return;
                }

                IQueryFilter filter = new QueryFilter();
                filter.WhereClause = fieldName + " like '%" + fieldValue + "%'";
                cursor             = fc.Search(filter, false);
                while ((row = cursor.NextRow()) != null)
                {
                    DataRow dr = this._dt.NewRow();
                    dr["geo"]    = row.GetValue(geoIndex);
                    dr["fid"]    = row.GetValue(fidIndex);
                    dr["Name"]   = row.GetValue(nameIndex);
                    dr["fcName"] = string.IsNullOrEmpty(fc.AliasName) ? fc.Name : fc.AliasName;
                    this._dt.Rows.Add(dr);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
示例#14
0
文件: MainForm.cs 项目: batuZ/Samples
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            this.axRenderControl1.FeatureManager.UnhighlightAll();

            // 置空
            _buffer       = null;
            _featureLayer = null;

            if (PickResult != null)
            {
                switch (PickResult.Type)
                {
                case gviObjectType.gviObjectFeatureLayer:
                {
                    IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult;
                    int fid = flpr.FeatureId;
                    //加载多FeatureClass时要每次重新获取
                    _featureClass = (IFeatureClass)fcGUIDMap[flpr.FeatureLayer.FeatureClassId];
                    _featureLayer = flpr.FeatureLayer;

                    IFdeCursor cursor = null;
                    try
                    {
                        _buffer = _featureClass.CreateRowBuffer();
                        QueryFilter filter = new QueryFilter();
                        //filter.AddSubField("oid");  //注意:StartEditFeatureGeometry里必须传入一个完整的rowbuffer,所以这里不能限定字段
                        filter.WhereClause = "oid =" + fid;
                        cursor             = _featureClass.Search(filter, false);
                        IRowBuffer row = null;
                        if ((row = cursor.NextRow()) != null)
                        {
                            _buffer = row as IRowBuffer;
                            int pos = _buffer.FieldIndex("Geometry");
                            oldfdeGeometry = _buffer.GetValue(pos) as IGeometry;
                        }
                    }
                    catch (COMException ex)
                    {
                        System.Diagnostics.Trace.WriteLine(ex.Message);
                    }
                    finally
                    {
                    }

                    this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow);
                    EditGeometry();
                }
                break;
                }
            }
        }
示例#15
0
        public bool InsertRow(IDataSource ds, string tname, object[] values)
        {
            ITable           table            = ds.OpenTable(tname);
            IFdeCursor       fdeCursor        = table.Insert();
            RowBufferFactory rowBufferFactory = new RowBufferFactoryClass();
            IRowBuffer       rowBuffer        = rowBufferFactory.CreateRowBuffer(table.GetFields());

            for (int i = 1; i <= values.Length; i++)
            {
                rowBuffer.SetValue(i, values[i]);
            }
            fdeCursor.InsertRow(rowBuffer);
            return(true);
        }
示例#16
0
        public int AppendByTable(ITable tar, ITable src, IPropertySet ps, IFeatureProgress fp)
        {
            int          num         = -1;
            IFdeCursor   fdeCursor   = null;
            IQueryFilter queryFilter = new QueryFilterClass();
            int          result;

            try
            {
                IDataCopy     dataCopy      = new DataCopyClass();
                DataCopyParam dataCopyParam = new DataCopyParamClass();
                queryFilter.WhereClause = "1=1";
                fdeCursor = src.Search(queryFilter, false);
                dataCopyParam.SetFieldMapping(ps);
                dataCopyParam.Filter  = queryFilter;
                dataCopyParam.KeepFid = true;
                dataCopyParam.ResourceConflictPolicy = gviResourceConflictPolicy.gviResourceRenameToNew;
                System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                num    = dataCopy.CopyTable(tar.DataSource, tar.TableName, src.DataSource, src.TableName, dataCopyParam);
                result = num;
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                XtraMessageBox.Show(ex.Message);
                LoggingService.Error(ex.Message + "\r\n" + ex.StackTrace);
                result = num;
            }
            catch (System.Exception ex2)
            {
                XtraMessageBox.Show(ex2.Message);
                LoggingService.Error(ex2.Message + "\r\n" + ex2.StackTrace);
                result = num;
            }
            finally
            {
                if (fdeCursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                    fdeCursor = null;
                }
            }
            return(result);
        }
示例#17
0
        public override void Run(object sender, System.EventArgs e)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            try
            {
                Map3DCommandManager.Push(this);
                RenderControlEditServices.Instance().StopGeometryEdit(true);
                app.Current3DMapControl.PauseRendering(false);
                System.Collections.Generic.IList <System.Collections.Generic.KeyValuePair <int, string> > list = new System.Collections.Generic.List <System.Collections.Generic.KeyValuePair <int, string> >();
                HashMap          featureClassInfoMap              = SelectCollection.Instance().FeatureClassInfoMap;
                DF3DFeatureClass featureClassInfo                 = null;
                System.Collections.Generic.IList <int> list2      = new System.Collections.Generic.List <int>();
                System.Collections.IEnumerator         enumerator = featureClassInfoMap.Keys.GetEnumerator();
                try
                {
                    if (enumerator.MoveNext())
                    {
                        DF3DFeatureClass featureClassInfo2 = (DF3DFeatureClass)enumerator.Current;
                        featureClassInfo = featureClassInfo2;
                        ResultSetInfo resultSetInfo = featureClassInfoMap[featureClassInfo2] as ResultSetInfo;
                        foreach (DataRow dataRow in resultSetInfo.ResultSetTable.Rows)
                        {
                            int    num   = int.Parse(dataRow[featureClassInfo.GetFeatureClass().FidFieldName].ToString());
                            string value = num.ToString();
                            System.Collections.Generic.KeyValuePair <int, string> item = new System.Collections.Generic.KeyValuePair <int, string>(num, value);
                            list.Add(item);
                            list2.Add(num);
                        }
                    }
                }
                finally
                {
                    System.IDisposable disposable = enumerator as System.IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                if (featureClassInfo != null)
                {
                    using (MergeDlg mergeDlg = new MergeDlg(list))
                    {
                        if (mergeDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            if (System.Windows.Forms.DialogResult.No != XtraMessageBox.Show("模型合并不支持撤销操作,是否继续?", "提示", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Exclamation))
                            {
                                int fid = mergeDlg.Fid;
                                using (new WaitDialogForm("", "正在进行模型合并,请稍后..."))
                                {
                                    IFeatureClass    featureClass      = featureClassInfo.GetFeatureClass();
                                    string           geometryFieldName = featureClassInfo.GetFeatureLayer().GeometryFieldName;
                                    IModelPoint      model             = this.GetModel(featureClass, geometryFieldName, fid);
                                    IResourceManager resourceManager   = CommonUtils.Instance().GetCurrentFeatureDataset() as IResourceManager;
                                    if (resourceManager != null)
                                    {
                                        if (!this.MergeModels(featureClass, geometryFieldName, list2.ToArray <int>(), resourceManager, ref model))
                                        {
                                            XtraMessageBox.Show("模型合并失败!");
                                        }
                                        else
                                        {
                                            if (list2.Remove(fid))
                                            {
                                                featureClass.Delete(new QueryFilterClass
                                                {
                                                    IdsFilter = list2.ToArray <int>()
                                                });
                                                CommonUtils.Instance().Delete(featureClassInfo, list2.ToArray <int>());
                                                app.Current3DMapControl.FeatureManager.DeleteFeatures(featureClass, list2.ToArray <int>());
                                            }
                                            app.Current3DMapControl.RefreshModel(CommonUtils.Instance().GetCurrentFeatureDataset(), model.ModelName);
                                            IFdeCursor fdeCursor = featureClass.Update(new QueryFilterClass
                                            {
                                                IdsFilter = new int[]
                                                {
                                                    fid
                                                }
                                            });
                                            IRowBuffer rowBuffer = fdeCursor.NextRow();
                                            if (rowBuffer != null)
                                            {
                                                int num2 = rowBuffer.FieldIndex(geometryFieldName);
                                                if (num2 != -1)
                                                {
                                                    rowBuffer.SetValue(num2, model);
                                                }
                                                fdeCursor.UpdateRow(rowBuffer);
                                                System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                                                app.Current3DMapControl.FeatureManager.EditFeature(featureClass, rowBuffer);
                                            }
                                            //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
            catch (System.UnauthorizedAccessException var_23_389)
            {
                XtraMessageBox.Show("拒绝访问");
            }
            catch (System.Exception ex2)
            {
                XtraMessageBox.Show(ex2.Message);
            }
            finally
            {
                app.Current3DMapControl.ResumeRendering();
            }
        }
示例#18
0
        private bool MergeModels(IFeatureClass fc, string geometryField, int[] oidList, IResourceManager resMgr, ref IModelPoint desModelPoint)
        {
            bool flag = true;
            bool result;

            try
            {
                if (fc == null || oidList == null)
                {
                    result = false;
                    return(result);
                }
                Gvitech.CityMaker.Resource.IModel model = resMgr.GetModel(desModelPoint.ModelName);
                IMatrix matrix = desModelPoint.AsMatrix().Clone();
                matrix.Inverse();
                int        position = fc.GetFields().IndexOf(geometryField);
                IFdeCursor rows     = fc.GetRows(oidList, false);
                IVector3   src      = new Vector3Class();
                IVector3   vector   = new Vector3Class();
                System.Collections.Generic.Dictionary <IMatrix, string> dictionary = new System.Collections.Generic.Dictionary <IMatrix, string>();
                IRowBuffer rowBuffer;
                while ((rowBuffer = rows.NextRow()) != null)
                {
                    IModelPoint modelPoint = rowBuffer.GetValue(position) as IModelPoint;
                    if (modelPoint != null)
                    {
                        dictionary[modelPoint.AsMatrix().Clone()] = modelPoint.ModelName;
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(modelPoint);
                    }
                }
                foreach (IMatrix current in dictionary.Keys)
                {
                    string name = dictionary[current];
                    Gvitech.CityMaker.Resource.IModel model2 = resMgr.GetModel(name);
                    for (int i = 0; i < model2.GroupCount; i++)
                    {
                        Gvitech.CityMaker.Resource.IDrawGroup drawGroup = new DrawGroupClass();
                        Gvitech.CityMaker.Resource.IDrawGroup group     = model2.GetGroup(i);
                        for (int j = 0; j < group.PrimitiveCount; j++)
                        {
                            Gvitech.CityMaker.Resource.IDrawPrimitive primitive = group.GetPrimitive(j);
                            if (primitive.PrimitiveType == Gvitech.CityMaker.Resource.gviPrimitiveType.gviPrimitiveBillboardZ)
                            {
                                flag   = false;
                                result = flag;
                                return(result);
                            }
                            Gvitech.CityMaker.Resource.IDrawPrimitive drawPrimitive = new DrawPrimitiveClass();
                            IFloatArray vertexArray = primitive.VertexArray;
                            IFloatArray floatArray  = new FloatArrayClass();
                            int         num         = 0;
                            while ((long)num < (long)((ulong)vertexArray.Length))
                            {
                                vector.X = (double)vertexArray.Get(num);
                                vector.Y = (double)vertexArray.Get(num + 1);
                                vector.Z = (double)vertexArray.Get(num + 2);
                                current.MultiplyVector(vector, ref src);
                                matrix.MultiplyVector(src, ref vector);
                                floatArray.Append((float)vector.X);
                                floatArray.Append((float)vector.Y);
                                floatArray.Append((float)vector.Z);
                                num += 3;
                            }
                            drawPrimitive.VertexArray        = floatArray;
                            drawPrimitive.BakedTexcoordArray = primitive.BakedTexcoordArray;
                            drawPrimitive.ColorArray         = primitive.ColorArray;
                            drawPrimitive.IndexArray         = primitive.IndexArray;
                            drawPrimitive.Material           = primitive.Material;
                            drawPrimitive.NormalArray        = primitive.NormalArray;
                            drawPrimitive.PrimitiveMode      = primitive.PrimitiveMode;
                            drawPrimitive.PrimitiveType      = primitive.PrimitiveType;
                            drawPrimitive.TexcoordArray      = primitive.TexcoordArray;
                            drawGroup.AddPrimitive(drawPrimitive);
                        }
                        drawGroup.CompleteMapFactor      = group.CompleteMapFactor;
                        drawGroup.CompleteMapTextureName = group.CompleteMapTextureName;
                        drawGroup.LightMapTextureName    = group.LightMapTextureName;
                        model.AddGroup(drawGroup);
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(model2);
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(rows);
                desModelPoint.ModelEnvelope = model.Envelope.Clone();
                resMgr.UpdateModel(desModelPoint.ModelName, model);
                resMgr.RebuildSimplifiedModel(desModelPoint.ModelName);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(matrix);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(model);
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                flag = false;
                XtraMessageBox.Show(ex.Message);
            }
            catch (System.Exception e)
            {
                flag = false;
                LoggingService.Error(e);
            }
            result = flag;
            return(result);
        }
示例#19
0
        /// <summary>
        /// 鼠标点击 拾取分析点
        /// </summary>
        /// <param name="PickResult"></param>
        /// <param name="IntersectPoint"></param>
        /// <param name="Mask"></param>
        /// <param name="EventSender"></param>
        void g_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (IntersectPoint == null)
            {
                return;
            }

            if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectClick))
            {
                mouseClicks++;
                if (mouseClicks % 2 == 1)
                {
                    this.label7.Text = "请鼠标点击选择目标点";
                    this.startX.Text = IntersectPoint.X.ToString();
                    this.startY.Text = IntersectPoint.Y.ToString();
                    this.startZ.Text = (IntersectPoint.Z + double.Parse(numZOffset.Value.ToString())).ToString();

                    axRenderControl1.MouseSelectMode = gviMouseSelectMode.gviMouseSelectClick | gviMouseSelectMode.gviMouseSelectMove;
                }
                else
                {
                    this.label7.Text             = "选择结束";
                    this.btnStartAnalyse.Enabled = true;

                    axRenderControl1.InteractMode          = gviInteractMode.gviInteractNormal;
                    axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectNone;
                    axRenderControl1.MouseSelectMode       = gviMouseSelectMode.gviMouseSelectClick;
                    axRenderControl1.RcMouseClickSelect   -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(g_RcMouseClickSelect);


                    geoRegion = axRenderControl1.HighlightHelper.GetRegion();
                    //开始空间查询
                    try
                    {
                        this.label7.Text = "开始空间查询";
                        ISpatialFilter sfilter = new SpatialFilter();
                        sfilter.Geometry      = geoRegion;
                        sfilter.SpatialRel    = gviSpatialRel.gviSpatialRelIntersects;
                        sfilter.GeometryField = "footprint";
                        cursor = buildingFC.Search(sfilter, false);
                        row    = null;
                        while ((row = cursor.NextRow()) != null)
                        {
                            int nfidpos = row.FieldIndex("Geometry");
                            if (nfidpos > -1)
                            {
                                geoInFC = row.GetValue(nfidpos) as IGeometry;
                            }
                            if (geoInFC != null)
                            {
                                //AddOcluder
                                axRenderControl1.VisualAnalysis.AddOccluder(buildingFL, geoInFC);

                                //highlight occluder
                                int fidpos = row.FieldIndex("oid");
                                if (fidpos > -1)
                                {
                                    axRenderControl1.FeatureManager.HighlightFeature(buildingFC, int.Parse(row.GetValue(fidpos).ToString()), System.Drawing.Color.Red);
                                }
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                    }
                    finally
                    {
                        if (cursor != null)
                        {
                            //Marshal.ReleaseComObject(cursor);
                            cursor = null;
                        }
                    }

                    this.label7.Text = "正在视域分析中...";
                    //StartAnalyse
                    axRenderControl1.VisualAnalysis.StartViewshedAnalyse(fde_point1, fde_point2, double.Parse(this.numHorizontalAngle.Value.ToString()));
                    axRenderControl1.HighlightHelper.VisibleMask = 0;
                    this.label7.Text = "分析结束";
                }
            }
            else if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectMove))
            {
                this.endX.Text = IntersectPoint.X.ToString();
                this.endY.Text = IntersectPoint.Y.ToString();
                this.endZ.Text = IntersectPoint.Z.ToString();

                fde_point1 = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPoint,
                                                       gviVertexAttribute.gviVertexAttributeZ) as IPoint;
                fde_point1.SetCoords(double.Parse(this.startX.Text), double.Parse(this.startY.Text), double.Parse(this.startZ.Text), 0, 0);
                fde_point2 = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPoint,
                                                       gviVertexAttribute.gviVertexAttributeZ) as IPoint;
                fde_point2.SetCoords(double.Parse(this.endX.Text), double.Parse(this.endY.Text), double.Parse(this.endZ.Text), 0, 0);
                axRenderControl1.HighlightHelper.SetSectorRegion(fde_point1, fde_point2, double.Parse(this.numHorizontalAngle.Value.ToString()));
            }
        }
示例#20
0
        private bool UpdateFacStyleClass(FacStyleClass style)
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IFeatureDataSet fds = this._ds.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(false);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_FacilityStyle");
                if (oc == null)
                {
                    return(false);
                }

                IQueryFilter filter = new QueryFilter()
                {
                    WhereClause = string.Format("ObjectId = '{0}'", style.ObjectId)
                };
                cursor = oc.Update(filter);
                row    = cursor.NextRow();
                if (row != null)
                {
                    row.SetValue(row.FieldIndex("Name"), style.Name);
                    row.SetValue(row.FieldIndex("FacClassCode"), style.FacClassCode);
                    row.SetValue(row.FieldIndex("ObjectId"), style.ObjectId);
                    row.SetValue(row.FieldIndex("StyleType"), style.Type.ToString());
                    row.SetValue(row.FieldIndex("StyleInfo"), style.ObjectToJson());
                    if (style.Thumbnail != null)
                    {
                        try
                        {
                            IBinaryBuffer bb     = new BinaryBufferClass();
                            MemoryStream  stream = new MemoryStream();
                            style.Thumbnail.Save(stream, ImageFormat.Png);
                            bb.FromByteArray(stream.ToArray());
                            row.SetValue(row.FieldIndex("Thumbnail"), bb);
                        }
                        catch (Exception exception)
                        {
                        }
                    }
                    cursor.UpdateRow(row);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
示例#21
0
        private DataTable GetTextureInfo()
        {
            DataTable  table  = null;
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                table = new DataTable("TextureInfo");
                table.Columns.Add("Name", typeof(string));
                table.Columns.Add("ObjectId", typeof(string));
                table.Columns.Add("Thumbnail", typeof(object));

                IFeatureDataSet fds = this._ds.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_TextureInfo");
                if (oc == null)
                {
                    return(null);
                }

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause   = "GroupId != '-1'",
                    SubFields     = "Name,ObjectId,Thumbnail",
                    PostfixClause = "order by Name asc"
                };
                cursor = oc.Search(filter, true);
                while ((row = cursor.NextRow()) != null)
                {
                    DataRow dtRow = table.NewRow();
                    dtRow["Name"]     = row.GetValue(0).ToString();
                    dtRow["ObjectId"] = row.GetValue(1).ToString();
                    if (!row.IsNull(2))
                    {
                        try
                        {
                            IBinaryBuffer buffer2 = row.GetValue(2) as IBinaryBuffer;
                            if (buffer2 != null)
                            {
                                MemoryStream stream = new MemoryStream(buffer2.AsByteArray());
                                dtRow["Thumbnail"] = Image.FromStream(stream);
                            }
                        }
                        catch (Exception exception)
                        {
                        }
                    }
                    table.Rows.Add(dtRow);
                }
                return(table);
            }
            catch (Exception exception)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
示例#22
0
        public static HashSet <string> GetValveIdsByFCGuid(string fcGuid)
        {
            if (ValveManager.Instance.Exists(fcGuid))
            {
                return(ValveManager.Instance.GetValveIds(fcGuid));
            }
            if (DF3DPipeCreateApp.App.PipeLib == null)
            {
                return(null);
            }
            IFeatureClass fc     = null;
            IQueryFilter  filter = null;
            IFdeCursor    cursor = null;
            IRowBuffer    buffer = null;

            try
            {
                if (dictFC.ContainsKey(fcGuid) && dictFC[fcGuid] != null)
                {
                    fc = dictFC[fcGuid];
                }
                else
                {
                    IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_GEO_Actuality");
                    if (fds == null)
                    {
                        return(null);
                    }
                    string[] fcNames = fds.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                    if (fcNames == null)
                    {
                        return(null);
                    }
                    foreach (string fcName in fcNames)
                    {
                        IFeatureClass fcTemp = fds.OpenFeatureClass(fcName);
                        if (fcTemp.GuidString == fcGuid)
                        {
                            fc = fcTemp;
                            break;
                        }
                    }
                    if (fc == null)
                    {
                        return(null);
                    }
                    FacilityClass fac = FacilityClassManager.Instance.GetFacilityClassByName("PipeNode");
                    if (fac == null)
                    {
                        return(null);
                    }
                    DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("Additional");
                    if (fi == null)
                    {
                        return(null);
                    }

                    filter = new QueryFilterClass
                    {
                        SubFields   = "oid," + fi.Name,
                        WhereClause = fi.Name + " LIKE '%阀%'"//改
                    };
                    int count = fc.GetCount(filter);
                    if (count == 0)
                    {
                        return(null);
                    }
                    cursor = fc.Search(filter, false);
                    HashSet <string> hsRes = new HashSet <string>();
                    while ((buffer = cursor.NextRow()) != null)
                    {
                        hsRes.Add(fc.GuidString + "_" + buffer.GetValue(0).ToString());
                    }
                    ValveManager.Instance.Add(fcGuid, hsRes);
                    return(hsRes);
                }
                return(null);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (buffer != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(buffer);
                    buffer = null;
                }
            }
        }
示例#23
0
        void aaa(IFeatureClass fc, int index, IResourceManager resourceM)
        {
            //无条件查询,即全选
            IFdeCursor sourceCursor = fc.Update(null);
            IRowBuffer row          = null;

            //遍历feature
            while ((row = sourceCursor.NextRow()) != null)
            {
                //从feature中拿到几何属性
                IGeometry geom = (IGeometry)row.GetValue(index);
                //确定是模型
                if (geom.GeometryType == gviGeometryType.gviGeometryModelPoint)
                {
                    //转换为modelPoint
                    IModelPoint mp = (IModelPoint)geom;

                    //mp 的转换矩阵
                    IMatrix mx = mp.AsMatrix();

                    //获取模型实例
                    //注意:
                    //model可以被不同的modelPoint多次引用,需要修改模型时
                    //需要通过modelName判断一下,这个模型被修改过没有
                    IModel model = resourceM.GetModel(mp.ModelName);

                    //提取模型节点属性
                    if (model != null)
                    {
                        #region modelInside
                        //遍历DrawGroup
                        for (int dgrpi = 0; dgrpi < model.GroupCount; dgrpi++)
                        {
                            IDrawGroup dgrp = model.GetGroup(dgrpi);
                            if (dgrp != null)
                            {
                                //遍历DrawPrimitive
                                for (int dpri = 0; dpri < dgrp.PrimitiveCount; dpri++)
                                {
                                    IDrawPrimitive dpr = dgrp.GetPrimitive(dpri);
                                    if (dpr != null)
                                    {
                                        //获取顶点数组
                                        float[] verArray = dpr.VertexArray.Array;
                                        //创建新的顶点数组,替换原来的
                                        IFloatArray newArr = new FloatArray();

                                        //遍历数组,转为点,三个成员为一组,xyz
                                        for (int veri = 0; veri < verArray.Length; veri += 3)
                                        {
                                            Vector3 vec = new Vector3();
                                            vec.X = verArray[veri];
                                            vec.Y = verArray[veri + 1];
                                            vec.Z = verArray[veri + 2];

                                            //用矩阵转到决对坐标,并修改
                                            IVector3 refVec = mx.MultiplyVector(vec);

                                            //修改部份
                                            refVec.X = 3.3;
                                            refVec.Y = 4.4;
                                            refVec.Z = 5.5;

                                            //修改完,减掉mp中的位移,准备塞回modle
                                            newArr.Append((float)(refVec.X - mp.X));
                                            newArr.Append((float)(refVec.Y - mp.Y));
                                            newArr.Append((float)(refVec.Z - mp.Z));
                                        }
                                        //把新顶点数组塞入Primitive
                                        dpr.VertexArray = newArr;
                                        //再把Primitive更新到当前Group
                                        dgrp.SetPrimitive(dpri, dpr);
                                    }
                                }
                                //把组更新到当前model
                                model.SetGroup(dgrpi, dgrp);
                            }
                        }
                        //更新数据源
                        resourceM.UpdateModel(mp.ModelName, model);
                        resourceM.RebuildSimplifiedModel(mp.ModelName);//重建简模
                        //释放资源
                        model.Dispose();
                        model = null;
                        #endregion
                    }

                    //修改mp
                    mp.SetCoords(3.3, 4.4, 5.5, mp.M, mp.Id);
                    //塞回row
                    row.SetValue(index, mp);
                }
            }
        }
示例#24
0
        public TopoNetwork GetNetwork()
        {
            if (TopoNetworkManager.Instance.Exists(this._objectId))
            {
                return(TopoNetworkManager.Instance.GetTopoNetWorkByObjectId(this._objectId));
            }

            if (DF3DPipeCreateApp.App.PipeLib == null)
            {
                return(null);
            }
            TopoNetwork   network = null;
            IFeatureClass class2  = null;
            IQueryFilter  filter  = null;
            IFdeCursor    cursor  = null;
            IRowBuffer    buffer  = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                class2 = fds.OpenFeatureClass(this._topotable);
                filter = new QueryFilterClass
                {
                    SubFields = "A_FacClass,Edge,P_FacClass,PNode,E_FacClass,ENode,Geometry"
                };

                Dictionary <string, Node> dictNode = new Dictionary <string, Node>();  // 点字典
                int totalcount = class2.GetCount(null);
                int loop       = (int)Math.Ceiling((decimal)(totalcount / 1000.0));
                for (int i = 1; i <= loop; i++)
                {
                    if (i == 1)
                    {
                        filter.ResultBeginIndex = 0;
                    }
                    else
                    {
                        filter.ResultBeginIndex = (i - 1) * 1000;
                    }
                    filter.ResultLimit = 1000;
                    cursor             = class2.Search(filter, true);
                    while ((buffer = cursor.NextRow()) != null)
                    {
                        string edgeFC, edgeOid, snodeFC, snodeOid, enodeFC, enodeOid;
                        if (!buffer.IsNull(0))
                        {
                            edgeFC = buffer.GetValue(0).ToString();
                        }
                        else
                        {
                            edgeFC = "0";
                        }

                        if (!buffer.IsNull(1))
                        {
                            edgeOid = buffer.GetValue(1).ToString();
                        }
                        else
                        {
                            edgeOid = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant();
                        }

                        if (!buffer.IsNull(2))
                        {
                            snodeFC = buffer.GetValue(2).ToString();
                        }
                        else
                        {
                            snodeFC = "0";
                        }

                        if (!buffer.IsNull(3))
                        {
                            snodeOid = buffer.GetValue(3).ToString();
                        }
                        else
                        {
                            snodeOid = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant();
                        }

                        if (!buffer.IsNull(4))
                        {
                            enodeFC = buffer.GetValue(4).ToString();
                        }
                        else
                        {
                            enodeFC = "0";
                        }

                        if (!buffer.IsNull(5))
                        {
                            enodeOid = buffer.GetValue(5).ToString();
                        }
                        else
                        {
                            enodeOid = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant();
                        }

                        double edgeLength = double.MaxValue;
                        if (!buffer.IsNull(6) && buffer.GetValue(6) is IPolyline)
                        {
                            IPolyline line = buffer.GetValue(6) as IPolyline;
                            edgeLength = line.Length;
                        }

                        Node   sn  = null;
                        Node   en  = null;
                        string key = snodeFC + "_" + snodeOid;
                        if (!dictNode.ContainsKey(key))
                        {
                            if (NodeManager.Instance.GetNodeByID(key) == null)
                            {
                                sn = new Node(snodeFC, snodeOid);
                                NodeManager.Instance.Add(sn);
                            }
                            else
                            {
                                sn = NodeManager.Instance.GetNodeByID(key);
                            }
                            dictNode.Add(key, sn);
                        }
                        else
                        {
                            sn = dictNode[key];
                        }
                        key = enodeFC + "_" + enodeOid;
                        if (!dictNode.ContainsKey(key))
                        {
                            if (NodeManager.Instance.GetNodeByID(key) == null)
                            {
                                en = new Node(enodeFC, enodeOid);
                                NodeManager.Instance.Add(en);
                            }
                            else
                            {
                                en = NodeManager.Instance.GetNodeByID(key);
                            }
                            dictNode.Add(key, en);
                        }
                        else
                        {
                            en = dictNode[key];
                        }
                        if (sn == null || en == null)
                        {
                            continue;
                        }
                        Edge e = new Edge(edgeFC, edgeOid, sn, en, edgeLength);
                        EdgeManager.Instance.Add(e);
                    }
                }
                network = new TopoNetwork(this._objectId, dictNode);
                TopoNetworkManager.Instance.Add(this.ObjectId, network);
                return(network);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (buffer != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(buffer);
                    buffer = null;
                }
            }
        }
示例#25
0
        private TextureClass GetTextureClass(string objectId)
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IDataSource ds = DF3DPipeCreateApp.App.TemplateLib;
                if (ds == null)
                {
                    return(null);
                }
                IFeatureDataSet fds = ds.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_TextureInfo");
                if (oc == null)
                {
                    return(null);
                }

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause = "ObjectId = '" + objectId + "'"
                };
                cursor = oc.Search(filter, true);
                if ((row = cursor.NextRow()) != null)
                {
                    int    id = -1;
                    string name = "", objectid = "", groupid = "", code = "", comment = "";
                    Image  thumbnail = null;
                    int    index     = row.FieldIndex("oid");
                    if (index != -1 && !row.IsNull(index))
                    {
                        id = Convert.ToInt32(row.GetValue(index).ToString());
                    }
                    index = row.FieldIndex("Name");
                    if (index != -1 && !row.IsNull(index))
                    {
                        name = row.GetValue(index).ToString();
                    }
                    index = row.FieldIndex("ObjectId");
                    if (index != -1 && !row.IsNull(index))
                    {
                        objectid = row.GetValue(index).ToString();
                    }
                    index = row.FieldIndex("GroupId");
                    if (index != -1 && !row.IsNull(index))
                    {
                        groupid = row.GetValue(index).ToString();
                    }
                    index = row.FieldIndex("Code");
                    if (index != -1 && !row.IsNull(index))
                    {
                        code = row.GetValue(index).ToString();
                    }
                    index = row.FieldIndex("Comment");
                    if (index != -1 && !row.IsNull(index))
                    {
                        comment = row.GetValue(index).ToString();
                    }
                    index = row.FieldIndex("Thumbnail");
                    if (index != -1 && !row.IsNull(index))
                    {
                        IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer;
                        if (row != null)
                        {
                            MemoryStream stream = new MemoryStream(b.AsByteArray());
                            thumbnail = Image.FromStream(stream);
                        }
                    }
                    if (id != -1 && thumbnail != null)
                    {
                        TextureClass cc = new TextureClass();
                        cc.Id        = id; cc.Name = name; cc.Group = groupid;
                        cc.ObjectId  = objectid; cc.Code = code; cc.Comment = comment;
                        cc.Thumbnail = thumbnail;
                        return(cc);
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
示例#26
0
        public static List <FacClassReg> GetFacClassRegsByFacilityType(string str)
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_FacilityClass");
                if (oc == null)
                {
                    return(null);
                }

                IQueryFilter filter = new QueryFilter();
                filter.WhereClause = "FacilityType='" + str + "'";

                cursor = oc.Search(filter, false);
                List <FacClassReg> list = new List <FacClassReg>();
                while ((row = cursor.NextRow()) != null)
                {
                    FacClassReg fc = new FacClassReg();
                    if (row.FieldIndex("oid") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("oid"));
                        if (obj != null)
                        {
                            fc.Id = int.Parse(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("Name") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Name"));
                        if (obj != null)
                        {
                            fc.Name = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("FacClassCode") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("FacClassCode"));
                        if (obj != null)
                        {
                            fc.FacClassCode = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("DataSetName") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("DataSetName"));
                        if (obj != null)
                        {
                            fc.DataSetName = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("FeatureClassId") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("FeatureClassId"));
                        if (obj != null)
                        {
                            fc.FeatureClassId = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("FcName") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("FcName"));
                        if (obj != null)
                        {
                            fc.FcName = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("DataType") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("DataType"));
                        if (obj != null)
                        {
                            DataLifeCyle ts = 0;
                            if (Enum.TryParse <DataLifeCyle>(obj.ToString(), out ts))
                            {
                                fc.DataType = ts;
                            }
                            else
                            {
                                fc.DataType = 0;
                            }
                        }
                    }
                    if (row.FieldIndex("Comment") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Comment"));
                        if (obj != null)
                        {
                            fc.Comment = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("TurnerStyle") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("TurnerStyle"));
                        if (obj != null)
                        {
                            TurnerStyle ts = 0;
                            if (Enum.TryParse <TurnerStyle>(obj.ToString(), out ts))
                            {
                                fc.TurnerStyle = ts;
                            }
                            else
                            {
                                fc.TurnerStyle = 0;
                            }
                        }
                    }
                    if (row.FieldIndex("FacilityType") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("FacilityType"));
                        if (obj != null)
                        {
                            fc.FacilityType = FacilityClassManager.Instance.GetFacilityClassByName(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("LocationType") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("LocationType"));
                        if (obj != null)
                        {
                            LocationType lt = 0;
                            if (Enum.TryParse <LocationType>(obj.ToString(), out lt))
                            {
                                fc.LocationType = lt;
                            }
                            else
                            {
                                fc.LocationType = 0;
                            }
                        }
                    }
                    list.Add(fc);
                }
                return(list);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
示例#27
0
        private void SpatialQuery()
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }

            try
            {
                HashMap        hashMap = new HashMap();
                IRowBuffer     buffer  = null;
                IFdeCursor     cursor  = null;
                ISpatialFilter filter  = null;
                IGeometry      geo2D   = this._drawTool.GetGeo();
                if (geo2D != null && geo2D.GeometryType == gviGeometryType.gviGeometryPolygon)
                {
                    IPolygon polygon = geo2D as IPolygon;
                    if (polygon != null)
                    {
                        DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer;
                        if (featureClassInfo != null)
                        {
                            IFeatureClass featureClass = featureClassInfo.GetFeatureClass();
                            if (featureClass != null)
                            {
                                string typeName = featureClassInfo.GetFacilityClassName();
                                if (typeName == "PipeLine" || typeName == "PipeNode" || typeName == "PipeBuild" || typeName == "PipeBuild1")
                                {
                                    filter = new SpatialFilterClass
                                    {
                                        GeometryField = "Shape",
                                        SpatialRel    = gviSpatialRel.gviSpatialRelIntersects,
                                        Geometry      = polygon.Clone2(gviVertexAttribute.gviVertexAttributeNone)
                                    };
                                }
                                else
                                {
                                    filter = new SpatialFilterClass
                                    {
                                        Geometry      = polygon,
                                        GeometryField = "Geometry",
                                        SpatialRel    = gviSpatialRel.gviSpatialRelEnvelope
                                    };
                                }
                                filter.SubFields = featureClass.FidFieldName;
                                cursor           = featureClass.Search(filter, true);
                                while ((buffer = cursor.NextRow()) != null)
                                {
                                    int featureId = int.Parse(buffer.GetValue(0).ToString());
                                    if (hashMap.Contains(featureClassInfo))
                                    {
                                        System.Collections.Generic.List <int> list = hashMap[featureClassInfo] as System.Collections.Generic.List <int>;
                                        if (!list.Contains(featureId))
                                        {
                                            list.Add(featureId);
                                        }
                                    }
                                    else
                                    {
                                        System.Collections.Generic.List <int> list2 = new System.Collections.Generic.List <int>();
                                        if (!list2.Contains(featureId))
                                        {
                                            list2.Add(featureId);
                                        }
                                        hashMap[featureClassInfo] = list2;
                                    }
                                }
                            }
                        }
                    }
                    SelectCollection.Instance().UpdateSelection(hashMap);
                    RenderControlEditServices.Instance().SetEditorPosition(SelectCollection.Instance().FcRowBuffersMap);
                    this.Clear();
                }
                if (buffer != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(buffer);
                }
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                }
                if (filter != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(filter);
                }
            }
            catch (Exception ex)
            {
                LoggingService.Error(ex.Message);
            }
        }
示例#28
0
        private void treelist_AfterCheckNode(object sender, NodeEventArgs e)
        {
            this.teValue.Text = "";
            this.listBoxControlValues.Items.Clear();
            if (string.IsNullOrEmpty(this._sysFieldName))
            {
                return;
            }
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                WaitForm.Start("正在加载列表...", "请稍后");
                HashSet <string> list   = new HashSet <string>();
                bool             bBreak = false;
                foreach (TreeListNode node in this.treelist.GetAllCheckedNodes())
                {
                    object obj = node.GetValue("NodeObject");
                    if (obj != null && obj is SubClass)
                    {
                        SubClass sc = obj as SubClass;
                        if (sc.Parent == null)
                        {
                            continue;
                        }
                        string cacheType = sc.Parent.Name + "_" + sc.GroupId + "_3D_" + this._sysFieldName;
                        object objCache  = CacheHelper.GetCache(cacheType);
                        if (objCache != null && objCache is HashSet <string> )
                        {
                            HashSet <string> temphs = objCache as HashSet <string>;
                            foreach (string tempstr in temphs)
                            {
                                list.Add(tempstr);
                            }
                            continue;
                        }
                        HashSet <string> listsc    = new HashSet <string>();
                        string[]         arrFc3DId = sc.Parent.Fc3D.Split(';');
                        if (arrFc3DId == null)
                        {
                            continue;
                        }
                        foreach (string fc3DId in arrFc3DId)
                        {
                            DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId);
                            if (dffc == null)
                            {
                                continue;
                            }
                            FacilityClass facClass = dffc.GetFacilityClass();
                            IFeatureClass fc       = dffc.GetFeatureClass();
                            if (fc == null || facClass == null || facClass.Name != this._facType)
                            {
                                continue;
                            }
                            DFDataConfig.Class.FieldInfo fi = facClass.GetFieldInfoBySystemName(this._sysFieldName);
                            if (fi == null)
                            {
                                continue;
                            }
                            IFieldInfoCollection fiCol = fc.GetFields();
                            int index = fiCol.IndexOf(fi.Name);
                            if (index < 0)
                            {
                                continue;
                            }
                            Gvitech.CityMaker.FdeCore.FieldInfo gfi = (Gvitech.CityMaker.FdeCore.FieldInfo)fiCol.Get(index);
                            IQueryFilter filter = new QueryFilter();
                            filter.SubFields        = gfi.Name;
                            filter.ResultBeginIndex = 0;
                            filter.ResultLimit      = 1;
                            while (true)
                            {
                                string strTempClause = gfi.Name + " is not null and ";
                                string fClause       = strTempClause;
                                foreach (string strtemp in listsc)
                                {
                                    fClause += gfi.Name + " <> " + strtemp + " and ";
                                }
                                fClause            = fClause.Substring(0, fClause.Length - 5);
                                filter.WhereClause = "GroupId = " + sc.GroupId + " and " + fClause;

                                cursor = fc.Search(filter, true);
                                if ((row = cursor.NextRow()) != null)
                                {
                                    if (row.IsNull(0))
                                    {
                                        break;
                                    }
                                    object temp    = row.GetValue(0);
                                    string strtemp = "";
                                    switch (gfi.FieldType)
                                    {
                                    case gviFieldType.gviFieldFID:
                                    case gviFieldType.gviFieldFloat:
                                    case gviFieldType.gviFieldDouble:
                                    case gviFieldType.gviFieldInt16:
                                    case gviFieldType.gviFieldInt32:
                                    case gviFieldType.gviFieldInt64:
                                        strtemp = temp.ToString();
                                        break;

                                    case gviFieldType.gviFieldDate:
                                    case gviFieldType.gviFieldString:
                                    case gviFieldType.gviFieldUUID:
                                        strtemp = "'" + temp.ToString() + "'";
                                        break;

                                    case gviFieldType.gviFieldBlob:
                                    case gviFieldType.gviFieldGeometry:
                                    case gviFieldType.gviFieldUnknown:
                                    default:
                                        continue;
                                    }
                                    if (temp != null)
                                    {
                                        list.Add(strtemp);
                                        listsc.Add(strtemp);
                                        if (list.Count > 10)
                                        {
                                            bBreak = true;
                                            break;// 列举10个
                                        }
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            if (bBreak)
                            {
                                break;
                            }
                        }
                        CacheHelper.SetCache(cacheType, listsc);
                    }
                    if (bBreak)
                    {
                        break;
                    }
                }
                foreach (string str2 in list)
                {
                    //if (!(string.IsNullOrEmpty(str2)))
                    //{
                    this.listBoxControlValues.Items.Add(str2);
                    //}
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
                WaitForm.Stop();
            }
        }
示例#29
0
        public static List <FacStyleClass> GetFacStyleByFacClassCode(string fcCode)
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_FacilityStyle");
                if (oc == null)
                {
                    return(null);
                }

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause = string.Format("FacClassCode = '{0}'", fcCode)
                };
                cursor = oc.Search(filter, true);
                List <FacStyleClass> list = new List <FacStyleClass>();
                while ((row = cursor.NextRow()) != null)
                {
                    StyleType     type;
                    FacStyleClass fs = null;
                    if (row.FieldIndex("StyleType") >= 0 && Enum.TryParse <StyleType>(row.GetValue(row.FieldIndex("StyleType")).ToString(), out type))
                    {
                        Dictionary <string, string> dictionary = null;
                        if (row.FieldIndex("StyleInfo") >= 0)
                        {
                            object obj = row.GetValue(row.FieldIndex("StyleInfo"));
                            if (obj != null)
                            {
                                IBinaryBuffer buffer2 = row.GetValue(row.FieldIndex("StyleInfo")) as IBinaryBuffer;
                                if (buffer2 != null)
                                {
                                    dictionary = JsonTool.JsonToObject <Dictionary <string, string> >(Encoding.UTF8.GetString(buffer2.AsByteArray()));
                                }
                            }
                        }
                        switch (type)
                        {
                        case StyleType.PipeNodeStyle:
                            fs = new PipeNodeStyleClass(dictionary);
                            break;

                        case StyleType.PipeLineStyle:
                            fs = new PipeLineStyleClass(dictionary);
                            break;

                        case StyleType.PipeBuildStyle:
                            fs = new PipeBuildStyleClass(dictionary);
                            break;
                        }
                    }
                    if (fs == null)
                    {
                        continue;
                    }
                    if (row.FieldIndex("oid") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("oid"));
                        if (obj != null)
                        {
                            fs.Id = int.Parse(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("ObjectId") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("ObjectId"));
                        if (obj != null)
                        {
                            fs.ObjectId = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("FacClassCode") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("FacClassCode"));
                        if (obj != null)
                        {
                            fs.FacClassCode = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("Name") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Name"));
                        if (obj != null)
                        {
                            fs.Name = obj.ToString();
                        }
                    }
                    int index = row.FieldIndex("Thumbnail");
                    if (index != -1 && !row.IsNull(index))
                    {
                        IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer;
                        if (row != null)
                        {
                            MemoryStream stream = new MemoryStream(b.AsByteArray());
                            fs.Thumbnail = Image.FromStream(stream);
                        }
                    }
                    list.Add(fs);
                }
                return(list);
            }
            catch (Exception exception)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
示例#30
0
        public static TopoClass GetTopoClassByObjectId(string objectId)
        {
            if (dictTopo.ContainsKey(objectId) && dictTopo[objectId] != null)
            {
                return(dictTopo[objectId]);
            }
            if (DF3DPipeCreateApp.App.TemplateLib == null)
            {
                return(null);
            }

            IFdeCursor   o      = null;
            IRowBuffer   row    = null;
            IQueryFilter filter = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_TopoManage");
                if (oc == null)
                {
                    return(null);
                }
                filter = new QueryFilterClass
                {
                    WhereClause = string.Format("ObjectId = '{0}'", objectId)
                };
                o   = oc.Search(filter, true);
                row = o.NextRow();
                if (row != null)
                {
                    TopoClass tc = new TopoClass();
                    if (row.FieldIndex("oid") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("oid"));
                        if (obj != null)
                        {
                            tc.Id = int.Parse(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("ObjectId") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("ObjectId"));
                        if (obj != null)
                        {
                            tc.ObjectId = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("TopoLayerName") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("TopoLayerName"));
                        if (obj != null)
                        {
                            tc.Name = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("Tolerance") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Tolerance"));
                        if (obj != null)
                        {
                            tc.Tolerance = double.Parse(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("ToleranceZ") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("ToleranceZ"));
                        if (obj != null)
                        {
                            tc.ToleranceZ = double.Parse(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("IgnoreZ") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("IgnoreZ"));
                        if (obj != null)
                        {
                            tc.IgnoreZ = obj.ToString() == "1" ? true : false;
                        }
                    }
                    if (row.FieldIndex("TopoTableName") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("TopoTableName"));
                        if (obj != null)
                        {
                            tc.TopoTable = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("Comment") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Comment"));
                        if (obj != null)
                        {
                            tc.Comment = obj.ToString();
                        }
                    }
                    dictTopo[tc.ObjectId] = tc;
                    return(tc);
                }
                return(null);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (o != null)
                {
                    Marshal.ReleaseComObject(o);
                    o = null;
                }
                if (row != null)
                {
                    Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }