Esempio n. 1
0
        public void AddAutodeskFileTreeNode(AutodeskFileTreeNode treeNode, BXCModelEntities context = null)
        {
            try
            {

            context = context ?? new BXCModelEntities();
                var fileNodeRepo = new AutodeskFileTreeNodeRepository(context);
                fileNodeRepo.InsertNode(treeNode);
            }

            catch (Exception ex)
            {
                Log.Error("CreateNode Failed", ex);

            }
        }
Esempio n. 2
0
 public bool AddOrUpdateAutodeskFile(AutodeskFile file, bool overwrite, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
     var fileRepo = new AutodeskFileRepository(context);
     var existingFile = fileRepo.GetByNameAndOwner(file.Name, file.MC_OwnerId);
     if (existingFile == null)
     {
         fileRepo.InsertFile(file);
     }
     else
     {
         existingFile.TypeCatalogHeader = file.TypeCatalogHeader;
         fileRepo.UpdateFile(existingFile);
     }
     return true;
 }
Esempio n. 3
0
        public static void CreateBIMXchangeIndex()
        {
            var directory = FSDirectory.Open(
                                     new DirectoryInfo("C:\\LuceneIndex")
                                  );
            Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_29);
            var writer = new IndexWriter(directory, analyzer,
                                         IndexWriter.MaxFieldLength.UNLIMITED);

            //get all Revit Items
            using (var context = new BXCModelEntities())
            {
                var items = context.Items;
                foreach (var item in items)
                {
                    var doc = new Document();
                    doc.Add(new Field("id", item.Id.ToString(), Field.Store.YES, Field.Index.NO));
                    doc.Add(new Field("family", item.AutodeskFile.Name, Field.Store.YES, Field.Index.ANALYZED));
                    doc.Add(new Field("version", item.AutodeskFile.Version.ToString(), Field.Store.YES, Field.Index.ANALYZED));

                    var nodes = item.AutodeskFile.AutodeskFileTreeNodes;
                    var nodeString = nodes.Aggregate(string.Empty, (current, node) => string.Format("{0}{1} ", current, node.TreeNodes_Id));
                    doc.Add(new Field("nodes", nodeString, Field.Store.YES, Field.Index.ANALYZED));

                    var avaiableRevitVersions = item.AutodeskFile.RevitVersions
                                            .Aggregate(string.Empty, (current, version) =>
                                                current + string.Format("{0} ", version));
                    doc.Add(new Field("revitversion", avaiableRevitVersions, Field.Store.YES, Field.Index.ANALYZED));
                    doc.Add(new Field("name", item.Name, Field.Store.YES, Field.Index.ANALYZED));
                    foreach (var parameter in item.Parameters)
                    {
                        doc.Add(new Field(parameter.SearchName.Name, parameter.SearchValue.Value, Field.Store.YES, Field.Index.ANALYZED));
                    }

                    writer.AddDocument(doc);
                }
            }

            writer.Optimize();
            writer.Commit();
            writer.Close();
        }
Esempio n. 4
0
 public Library GetContentLibrary(string libraryName, string ownerId, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
         var libraryRepo = new LibraryRepository(context);
         return libraryRepo.GetByNameAndOwner(libraryName, ownerId);
 }
Esempio n. 5
0
 private TreeNode CreateNewTreeNode(string folder, int? parentId, int libraryId, BXCModelEntities context)
 {
     var nodeRepo = new TreeNodeRepository(context);
         var libraryRepo = new LibraryRepository(context);
         var newNode = new TreeNode
                           {
                               Name = folder,
                               TreeNode1 =
                                   parentId == null
                                       ? null
                                       : nodeRepo.GetByID(parentId.Value),
                               Library = libraryRepo.GetByID(libraryId)
                           };
         nodeRepo.AddTreeNode(newNode);
         return newNode;
 }
Esempio n. 6
0
        public bool RemoveNodes(IEnumerable<AutodeskFileTreeNode> Nodes, BXCModelEntities context = null)
        {
            context = context ?? new BXCModelEntities();

                var fileNodeRepo = new AutodeskFileTreeNodeRepository(context);

                foreach (var node in Nodes)
                {
                    fileNodeRepo.DeleteNode(node);
                }
                fileNodeRepo.SaveGroupChanges();
                return true;
        }
Esempio n. 7
0
 public void RemoveAutodeskFileTreeNode(AutodeskFileTreeNode treeNode, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
         var fileNodeRepo = new AutodeskFileTreeNodeRepository(context);
         fileNodeRepo.DeleteNode(treeNode);
 }
Esempio n. 8
0
        public bool RemoveAllTreeNodesForLibrary(string library, string owner, BXCModelEntities context = null)
        {
            context = context ?? new BXCModelEntities();

            var nodeRepo = new TreeNodeRepository(context);
            var treenodes = nodeRepo.GetAllByLibrary(library, owner);
            foreach (var treenode in treenodes)
            {
                nodeRepo.DeleteNode(treenode);
            }
            nodeRepo.SaveGroupChanges();
            return true;
        }
Esempio n. 9
0
 public bool RemoveAllAutodeskFileTreeNodesForLibrary(string library, string owner, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
         var fileNodeRepo = new AutodeskFileTreeNodeRepository(context);
         var aftreenodes = fileNodeRepo.GetAllByLibrary(library, owner);
         foreach (var aftreenode in aftreenodes)
         {
             fileNodeRepo.DeleteNode(aftreenode);
         }
         fileNodeRepo.SaveGroupChanges();
         return true;
 }
Esempio n. 10
0
 public TreeNode GetTreeNodeForLibary(string folder, int? parentId, int libraryId, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
         var nodeRepo = new TreeNodeRepository(context);
         return nodeRepo.GetByNameAndParentId(folder, parentId)
                ?? CreateNewTreeNode(folder, parentId, libraryId, context);
 }
Esempio n. 11
0
 public ItemRepository(BXCModelEntities context)
 {
     _context = context;
 }
Esempio n. 12
0
 public Library AddContentLibrary(string libraryName, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
         var libraryRepo = new LibraryRepository(context);
         return libraryRepo.AddLibrary(libraryName);
 }
Esempio n. 13
0
 public AutodeskFile GetAutodeskFileById(int family, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
         var fileRepo = new AutodeskFileRepository(context);
         return fileRepo.GetByID(family);
 }
Esempio n. 14
0
 public AutodeskFile GetAutodeskFile(string fileName, string ownerName, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
         var fileRepo = new AutodeskFileRepository(context);
         return fileRepo.GetByNameAndOwner(fileName, ownerName);
 }
Esempio n. 15
0
 public IEnumerable<AutodeskFileTreeNode> GetAllTreeNodesForLibrary(string libraryName, string ownerId, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
         var fileNodeRepo = new AutodeskFileTreeNodeRepository(context);
         return fileNodeRepo.GetAllByLibrary(libraryName, ownerId);
 }
Esempio n. 16
0
 public bool AddTypeToFile(Item item, string fileName, string owner, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
         var fileRepo = new AutodeskFileRepository(context);
         var existingFile = fileRepo.GetByNameAndOwner(fileName, owner);
         if (existingFile != null)
         {
             var itemRepo = new ItemRepository(context);
             var existingItem = itemRepo.GetByNameAndAutodeskFileName(fileName, item.Name, owner);
             if (existingItem == null)
             {
                 fileRepo.AddItem(item, existingFile);
                 return true;
             }
             Log.Error(string.Format("Item Not Added:{0} {1}", item.Name, fileName));
             //Should never occur - Deleting all Items on File update.
         }
         return false;
 }
Esempio n. 17
0
        public TreeNode AddTreeNode(TreeNode nextNode, BXCModelEntities context = null)
        {
            context = context ?? new BXCModelEntities();
            try
            {

                var nodeRepo = new TreeNodeRepository(context);

                return nodeRepo.AddTreeNode(nextNode);
                                }

            catch (Exception ex)
            {
                Log.Error("CreateNode Failed", ex);
                return null;
            }
        }
Esempio n. 18
0
 public TreeNode GetTreeNode(int value, BXCModelEntities context = null)
 {
     context = context ?? new BXCModelEntities();
     var nodeRepo = new TreeNodeRepository(context);
     return nodeRepo.GetByID(value);
 }
Esempio n. 19
0
 public AutodeskFileRepository(BXCModelEntities context)
 {
     _context = context;
 }