Beispiel #1
0
        private bool CreateFacClassReg(FacClass fc)
        {
            if (fc == null || fc.FacilityType == null)
            {
                return(false);
            }
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

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

                row    = oc.CreateRowBuffer();
                cursor = oc.Insert();
                if (row != null)
                {
                    row.SetValue(row.FieldIndex("FacClassCode"), fc.Code);
                    row.SetValue(row.FieldIndex("Name"), fc.Name);
                    row.SetValue(row.FieldIndex("FacilityType"), fc.FacilityType.Name);
                    row.SetValue(row.FieldIndex("LocationType"), fc.LocationType.ToString());
                    row.SetValue(row.FieldIndex("TurnerStyle"), fc.TurnerStyle.ToString());
                    row.SetValue(row.FieldIndex("Comment"), fc.Comment);
                    string fcName = string.Format("FC_{0}_{1}", (int)DataLifeCyle.Actuality, fc.Code);
                    List <CMFieldConfig> fieldConfig  = GetFieldsConfig(fc.Code);
                    IFieldInfoCollection fielInfoCol  = CreateFieldInfoCollection(fieldConfig, fc.FacilityType.Name);
                    IFeatureClass        featureClass = fdsActuality.CreateFeatureClass(fcName, fielInfoCol);
                    if (featureClass == null)
                    {
                        return(false);
                    }
                    featureClass.AliasName = fc.Name;
                    featureClass.LockType  = gviLockType.gviLockExclusiveSchema;
                    IGridIndexInfo indexInfo = new GridIndexInfoClass
                    {
                        L1            = 500.0,
                        L2            = 2000.0,
                        L3            = 10000.0,
                        GeoColumnName = "Geometry"
                    };
                    featureClass.AddSpatialIndex(indexInfo);
                    indexInfo.GeoColumnName = "Shape";
                    featureClass.AddSpatialIndex(indexInfo);
                    indexInfo.GeoColumnName = "FootPrint";
                    featureClass.AddSpatialIndex(indexInfo);
                    IRenderIndexInfo info2 = new RenderIndexInfoClass
                    {
                        L1            = 500.0,
                        GeoColumnName = "Geometry"
                    };
                    featureClass.AddRenderIndex(info2);
                    info2.GeoColumnName = "Shape";
                    featureClass.AddRenderIndex(info2);
                    info2.GeoColumnName = "FootPrint";
                    featureClass.AddRenderIndex(info2);
                    featureClass.LockType = gviLockType.gviLockSharedSchema;
                    row.SetValue(row.FieldIndex("FeatureClassId"), featureClass.Guid.ToString());
                    row.SetValue(row.FieldIndex("DataSetName"), "DataSet_GEO_Actuality");
                    row.SetValue(row.FieldIndex("FcName"), featureClass.Name);
                    row.SetValue(row.FieldIndex("DataType"), DataLifeCyle.Actuality.ToString());
                    cursor.InsertRow(row);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                WaitForm.SetCaption("创建管线库中的设施要素类【" + fc.Name + "】失败!");
                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;
                }
            }
        }
Beispiel #2
0
        private List <FacClass> GetAllFacClasses()
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

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

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause   = string.Format("FacilityType <> '{0}'", "UnKnown"),
                    PostfixClause = "order by OrderBy asc"
                };
                cursor = oc.Search(filter, true);
                List <FacClass> list = new List <FacClass>();
                while ((row = cursor.NextRow()) != null)
                {
                    FacClass fc = new FacClass();
                    if (row.FieldIndex("oid") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("oid"));
                        if (obj != null)
                        {
                            fc.Id = int.Parse(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("Code") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Code"));
                        if (obj != null)
                        {
                            fc.Code = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("PCode") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("PCode"));
                        if (obj != null)
                        {
                            fc.PCode = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("Comment") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Comment"));
                        if (obj != null)
                        {
                            fc.Comment = obj.ToString();
                        }
                    }
                    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)
                        {
                            fc.LocationType = (LocationType)Enum.Parse(typeof(LocationType), obj.ToString());
                        }
                    }
                    if (row.FieldIndex("TurnerStyle") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("TurnerStyle"));
                        if (obj != null)
                        {
                            fc.TurnerStyle = (TurnerStyle)Enum.Parse(typeof(TurnerStyle), obj.ToString());
                        }
                    }
                    if (row.FieldIndex("Name") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Name"));
                        if (obj != null)
                        {
                            fc.Name = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("TopoLayerId") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("TopoLayerId"));
                        if (obj != null)
                        {
                            fc.TopoLayerId = obj.ToString();
                        }
                    }
                    list.Add(fc);
                }
                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;
                }
            }
        }