示例#1
0
        public List <PipeLineFac> GetTopoPipeLine()
        {
            if (this._tc == null)
            {
                return(null);
            }
            if (DF3DPipeCreateApp.App.PipeLib == null)
            {
                return(null);
            }
            IQueryFilter filter = null;
            IFdeCursor   o      = null;
            IRowBuffer   r      = null;
            Dictionary <string, List <int> > dictionary  = null;
            Dictionary <string, FacClassReg> dictReg     = null;
            Dictionary <int, int>            dictionary2 = null;
            List <PipeLineFac> list = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IFeatureClass class2 = fds.OpenFeatureClass(this._tc.TopoTable);
                if (class2 == null)
                {
                    return(null);
                }
                filter = new QueryFilterClass
                {
                    WhereClause = string.Format("(P_FacClass = '{0}' and PNode = {1}) or (E_FacClass = '{0}' and ENode = {1})", this._facClassReg.FeatureClassId, base._oid),
                    SubFields   = "oid,A_FacClass,Edge,PNode,ENode"
                };
                int count = class2.GetCount(filter);
                if (count == 0)
                {
                    return(null);
                }
                dictionary  = new Dictionary <string, List <int> >();
                dictionary2 = new Dictionary <int, int>();
                dictReg     = new Dictionary <string, FacClassReg>();
                o           = class2.Search(filter, true);
                while ((r = o.NextRow()) != null)
                {
                    if (!r.IsNull(1) && !r.IsNull(2))
                    {
                        FacClassReg reg = GetFacClassReg(r.GetValue(1).ToString());
                        if (!dictionary.ContainsKey(reg.FacClassCode))
                        {
                            dictionary.Add(reg.FacClassCode, new List <int>());
                            dictReg.Add(reg.FacClassCode, reg);
                        }
                        dictionary[reg.FacClassCode].Add(Fac.GetInt(r, 2));
                        if (Fac.GetInt(r, 3) == this._oid)
                        {
                            dictionary2.Add(Fac.GetInt(r, 2), 0);
                        }
                        else
                        {
                            dictionary2.Add(Fac.GetInt(r, 2), 1);
                        }
                    }
                }
                if (dictionary.Count == 0)
                {
                    return(null);
                }
                list = new List <PipeLineFac>();
                foreach (KeyValuePair <string, List <int> > pair in dictionary)
                {
                    FacClassReg reg = dictReg[pair.Key];
                    if (reg.FacilityType.Name == "PipeLine")
                    {
                        IFeatureClass class3 = reg.GetFeatureClass();
                        o = class3.GetRows(pair.Value.ToArray(), false);
                        while ((r = o.NextRow()) != null)
                        {
                            int index = r.FieldIndex("StyleId");
                            if (index == -1)
                            {
                                continue;
                            }
                            FacStyleClass style = GetFacStyleByID(r.GetValue(index).ToString());
                            if (style != null)
                            {
                                PipeLineFac line = new PipeLineFac(reg, style, r, this._tc);
                                line.Tag = dictionary2[line.FeatureId];
                                list.Add(line);
                            }
                        }
                    }
                }
                return(list);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (o != null)
                {
                    Marshal.ReleaseComObject(o);
                    o = null;
                }
                if (r != null)
                {
                    Marshal.ReleaseComObject(r);
                    r = null;
                }
            }
        }