コード例 #1
0
        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;
                }
            }
        }
コード例 #2
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;
                }
            }
        }
コード例 #3
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;
                }
            }
        }
コード例 #4
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;
                }
            }
        }
コード例 #5
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;
                }
            }
        }
コード例 #6
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;
                }
            }
        }
コード例 #7
0
        public static Dictionary <string, IRowBuffer> GetPipeInfos(IConnectionInfo ci, string datasetName, string ocName)
        {
            Dictionary <string, IRowBuffer> infos = new Dictionary <string, IRowBuffer>();
            IFdeCursor   o      = null;
            IQueryFilter filter = null;
            IRowBuffer   r      = null;

            try
            {
                IDataSourceFactory dsFactory = new DataSourceFactory();
                if (!dsFactory.HasDataSource(ci))
                {
                    return(null);
                }
                IDataSource ds = dsFactory.OpenDataSource(ci);
                if (ds == null)
                {
                    return(null);
                }
                string[] setnames = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return(null);
                }
                for (int i = 0; i < setnames.Length; i++)
                {
                    if (setnames[i] != datasetName)
                    {
                        continue;
                    }
                    IFeatureDataSet fds = ds.OpenFeatureDataset(setnames[i]);
                    IObjectClass    oc  = fds.OpenObjectClass(ocName);
                    if (oc == null)
                    {
                        return(null);
                    }
                    filter = new QueryFilterClass
                    {
                        WhereClause = ""
                    };
                    o = oc.Search(filter, false);
                    while ((r = o.NextRow()) != null)
                    {
                        string code = r.GetValue(r.FieldIndex("Code")).ToString();
                        infos[code] = r;
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (filter != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(filter);
                    filter = null;
                }
                if (o != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
                    o = null;
                }
                if (r != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(r);
                    r = null;
                }
            }
            return(infos);
        }
コード例 #8
0
ファイル: SyncPipeLib.cs プロジェクト: wwcc19870805/DIFGIS
        private List <CMFieldConfig> GetFieldsConfig(string code)
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

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

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause   = string.Format("FacClassCode = '{0}'", code),
                    PostfixClause = "order by OrderBy asc"
                };
                cursor = oc.Search(filter, true);
                List <CMFieldConfig> list = new List <CMFieldConfig>();
                while ((row = cursor.NextRow()) != null)
                {
                    CMFieldConfig fc = new CMFieldConfig();
                    if (row.FieldIndex("oid") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("oid"));
                        if (obj != null)
                        {
                            fc.Id = int.Parse(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("FacClassCode") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("FacClassCode"));
                        if (obj != null)
                        {
                            fc.FacClassCode = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("Name") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Name"));
                        if (obj != null)
                        {
                            fc.Name = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("Alias") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Alias"));
                        if (obj != null)
                        {
                            fc.Alias = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("FieldType") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("FieldType"));
                        if (obj != null)
                        {
                            gviFieldType ts = 0;
                            if (Enum.TryParse <gviFieldType>(obj.ToString(), out ts))
                            {
                                fc.FieldType = ts;
                            }
                            else
                            {
                                fc.FieldType = gviFieldType.gviFieldUnknown;
                            }
                        }
                    }
                    if (row.FieldIndex("Length") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Length"));
                        if (obj != null)
                        {
                            fc.Length = Convert.ToInt32(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("Nullable") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Nullable"));
                        if (obj != null)
                        {
                            fc.Nullable = obj.ToString() == "0" ? false : true;
                        }
                    }
                    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;
                }
            }
        }
コード例 #9
0
ファイル: SyncPipeLib.cs プロジェクト: wwcc19870805/DIFGIS
        private List <TopoClass> GetAllTopoClasses()
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

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

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause = "1=1"
                };
                cursor = oc.Search(filter, true);
                List <TopoClass> list = new List <TopoClass>();
                while ((row = cursor.NextRow()) != 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();
                        }
                    }
                    list.Add(tc);
                }
                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;
                }
            }
        }
コード例 #10
0
ファイル: SyncPipeLib.cs プロジェクト: wwcc19870805/DIFGIS
        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;
                }
            }
        }
コード例 #11
0
ファイル: DataUtils.cs プロジェクト: wwcc19870805/DIFGIS
        private static List <Plan> SelectPlans(IDataSource ds, string WhereClause)
        {
            List <Plan> list   = new List <Plan>();
            IFdeCursor  cursor = null;
            IRowBuffer  row    = null;

            try
            {
                if (ds == null)
                {
                    return(list);
                }
                IFeatureDataSet fds = ds.OpenFeatureDataset("UP_PlanLibDs_Indication");
                if (fds == null)
                {
                    return(list);
                }
                IObjectClass class2 = fds.OpenObjectClass("UP_Plan");
                if (class2 != null)
                {
                    IQueryFilter filter = new QueryFilter
                    {
                        WhereClause = WhereClause
                    };
                    IFieldInfoCollection fiCol = class2.GetFields();
                    cursor = class2.Search(filter, true);
                    while ((row = cursor.NextRow()) != null)
                    {
                        Plan plan = new Plan
                        {
                            PlanID        = (row.IsNull(fiCol.IndexOf("oid"))) ? -1 : Convert.ToInt32(row.GetValue(fiCol.IndexOf("oid"))),
                            PlanGuid      = (row.IsNull(fiCol.IndexOf("planGuid"))) ? "" : row.GetValue(fiCol.IndexOf("planGuid")).ToString(),
                            PlanName      = (row.IsNull(fiCol.IndexOf("planName"))) ? "" : row.GetValue(fiCol.IndexOf("planName")).ToString(),
                            PlanCode      = (row.IsNull(fiCol.IndexOf("planCode"))) ? "" : row.GetValue(fiCol.IndexOf("planCode")).ToString(),
                            PlanDesigner  = (row.IsNull(fiCol.IndexOf("planDesigner"))) ? "" : row.GetValue(fiCol.IndexOf("planDesigner")).ToString(),
                            PlanState     = (row.IsNull(fiCol.IndexOf("planState"))) ? PlanState.None : (PlanState)row.GetValue(fiCol.IndexOf("planState")),
                            ProjectID     = (row.IsNull(fiCol.IndexOf("projectID"))) ? -1 : Convert.ToInt32(row.GetValue(fiCol.IndexOf("projectID"))),
                            XOffset       = (row.IsNull(fiCol.IndexOf("xOffset"))) ? double.NaN : Convert.ToDouble(row.GetValue(fiCol.IndexOf("xOffset"))),
                            YOffset       = (row.IsNull(fiCol.IndexOf("yOffset"))) ? double.NaN : Convert.ToDouble(row.GetValue(fiCol.IndexOf("yOffset"))),
                            Creator       = (row.IsNull(fiCol.IndexOf("creator"))) ? "" : row.GetValue(fiCol.IndexOf("creator")).ToString(),
                            CreateTime    = (row.IsNull(fiCol.IndexOf("createTime"))) ? DateTime.MinValue : (DateTime)row.GetValue(fiCol.IndexOf("createTime")),
                            AbandonReason = (row.IsNull(fiCol.IndexOf("abandonReason"))) ? "" : row.GetValue(fiCol.IndexOf("abandonReason")).ToString(),
                            Description   = (row.IsNull(fiCol.IndexOf("description"))) ? "" : row.GetValue(fiCol.IndexOf("description")).ToString(),
                            Bound         = (row.IsNull(fiCol.IndexOf("Bound"))) ? "" : row.GetValue(fiCol.IndexOf("Bound")).ToString(),
                            ConnType      = (row.IsNull(fiCol.IndexOf("ConnType"))) ? PlanType.None : (PlanType)row.GetValue(fiCol.IndexOf("ConnType"))
                        };
                        if (plan.ConnType == PlanType.Network)
                        {
                            list.Add(new NetWorkPlan(plan));
                        }
                        else
                        {
                            list.Add(new LocalPlan(plan));
                        }
                    }
                }
                return(list);
            }
            catch (Exception exception)
            {
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
            return(list);
        }