Exemplo n.º 1
0
 public static void Delete(ObjectId id, string key)
 {
     try {
         if (id.IsErased == false && id.IsEffectivelyErased == false)
         {
             using (World.Docu.LockDocument()) {
                 using (Database db = World.Docu.Database) {
                     using (Transaction tr = db.TransactionManager.StartTransaction()) {
                         using (DBDictionary dict = (DBDictionary)tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite, false)) {
                             if (dict.Contains(key))
                             {
                                 ObjectId deleteId = dict.GetAt(key);
                                 Xrecord  xRec     = (Xrecord)tr.GetObject(dict.GetAt(key), OpenMode.ForWrite, false);
                                 xRec.Erase();
                                 dict.Remove(deleteId);
                             }
                         }
                         tr.Commit();
                     }
                 }
             }
         }
     }
     catch (System.Exception ex) {
         Err.Log(ex);
     }
 }
Exemplo n.º 2
0
        public static void RemoveEntry2(
            DBDictionary dict, ObjectId id, Transaction tr)
        {
            ProxyObject obj =
                (ProxyObject)tr.GetObject(id, OpenMode.ForRead);

            // If you want to check what exact proxy it is

            /*if (obj.OriginalClassName != "ProxyToRemove")
             *  return;*/

            obj.UpgradeOpen();

            using (DBObject newObj = new Xrecord())
            {
                obj.HandOverTo(newObj, false, false);
                newObj.Erase();
            }
        }