Beispiel #1
0
        public void AddRec(RecXD recXd)
        {
            if (recXd == null || recXd.IsEmpty()) return;
            if (!IsCorrectName(recXd.Name))
                throw new Exception("Invalid Name - " + recXd.Name);

            if (Recs == null) Recs = new List<RecXD>();
            Recs.Add(recXd);
        }
Beispiel #2
0
        public static DicED GetDicEd(ObjectId dicId)
        {
            DicED res;

            if (!dicId.IsValidEx())
            {
                return(null);
            }

            using (var dic = dicId.Open(OpenMode.ForRead) as DBDictionary)
            {
                if (dic == null)
                {
                    return(null);
                }

                res = new DicED
                {
                    Inners = new List <DicED>(),
                    Recs   = new List <RecXD>()
                };

                foreach (var item in dic)
                {
                    if (item.Value.ObjectClass == General.ClassRecord)
                    {
                        using (var xrec = item.Value.Open(OpenMode.ForRead) as Xrecord)
                        {
                            if (xrec == null)
                            {
                                continue;
                            }
                            var values = xrec.Data.AsArray();
                            var rec    = new RecXD {
                                Name = item.Key, Values = values.ToList()
                            };
                            res.Recs.Add(rec);
                        }
                    }
                    else if (item.Value.ObjectClass == General.ClassDBDic)
                    {
                        var dicEdInner = GetDicEd(item.Value);
                        if (dicEdInner != null)
                        {
                            dicEdInner.Name = item.Key;
                            res.Inners.Add(dicEdInner);
                        }
                    }
                }
            }

            return(res);
        }
Beispiel #3
0
 public void AddRec([CanBeNull] RecXD recXd)
 {
     if (recXd == null || recXd.IsEmpty())
     {
         return;
     }
     if (!IsCorrectName(recXd.Name))
     {
         throw new Exception("Invalid Name - " + recXd.Name);
     }
     if (Recs == null)
     {
         Recs = new List <RecXD>();
     }
     Recs.Add(recXd);
 }
Beispiel #4
0
        /// <summary>
        /// Создание записи XRecord в словаре dicId
        /// </summary>
        /// <param name="dicId">Словарь DBDictionary</param>
        /// <param name="rec">Запись XRecord</param>
        public static void SetRecXD(ObjectId dicId, [CanBeNull] RecXD rec)
        {
            if (rec?.Values == null || rec.Values.Count == 0)
            {
                return;
            }
            var idXrec = GetRec(dicId, rec.Name, true, true);

            if (!idXrec.IsValidEx())
            {
                return;
            }

            using (var xrec = (Xrecord)idXrec.Open(OpenMode.ForWrite))
                using (var rb = new ResultBuffer(rec.Values.ToArray()))
                {
                    if (xrec != null)
                    {
                        xrec.Data = rb;
                    }
                }
        }