コード例 #1
0
        public void MapFolder()
        {
            // Traverse folders example
            Folder rootFolder = FileFolderService.GetFolderTree(Vault.RootFolder);

            rootFolder.Traverse(x =>
            {
                Debug.WriteLine(x.Path);

                // TODO: ...
            });

            // Traverse folders example
            var           fileRefsService = new FileReferencesService(Vault);
            FileReference fileRefTree     = fileRefsService.GetFileReference(@"C:\EPDMVaults\Training\Built Parts\Universal Joint_&.SLDASM");

            // traverse the tree in order to populate batch listing
            IEdmBatchListing2 listing = (IEdmBatchListing2)((IEdmBatchListing)Vault.CreateUtility(EdmUtility.EdmUtil_BatchList));

            fileRefTree.Traverse(x =>
            {
                Debug.WriteLine(x.File.Path);
                listing.AddFileCfg(x.File.Path, DateTime.Now, x.File.Id, "@", (int)EdmListFileFlags.EdmList_Nothing);
            });
        }
コード例 #2
0
        public FileReference GetFileReference(string filePath, string[] variableNames, string config)
        {
            FileReference fileRef = GetFileReference(filePath);

            // traverse the tree in order to populate batch listing
            IEdmBatchListing2 listing = (IEdmBatchListing2)((IEdmBatchListing)Vault.CreateUtility(EdmUtility.EdmUtil_BatchList));

            fileRef.Traverse(x =>
            {
                Debug.WriteLine(x.File.Path);
                listing.AddFileCfg(x.File.Path, DateTime.Now, x.File.Id, config, (int)EdmListFileFlags.EdmList_Nothing);
            });

            // create the list
            EdmListCol[] lstCols = null;
            listing.CreateListEx("\n" + string.Join("\n", variableNames), (int)EdmCreateListExFlags.Edmclef_MayReadFiles, ref lstCols);

            // populate the listing
            EdmListFile[] lstFiles = null;
            listing.GetFiles(ref lstFiles);

            int totalNodes = fileRef.Enumerate().Count();

            Debug.WriteLine(totalNodes);
            foreach (var f in fileRef.Enumerate())
            {
                Debug.WriteLine(f.File.Path);
            }

            Debug.Assert(lstFiles.Length == totalNodes);

            foreach (EdmListFile lf in lstFiles)
            {
                // Get the FileReference data model instance that corresponds to the current EdmListFile result instance in the loop.
                // The Enumerate member of FileReference was created for this purpose (supporting LINQ/Lamba expressions).
                var fileRefForLf = fileRef.Enumerate().Single(x => x.File.Id == lf.mlFileID && lf.mlFolderID == x.File.FolderId);

                // iterate over current file's variable values

                Debug.WriteLine("file (id: " + lf.mlFileID + ") variable values:");
                string[] values = lf.moColumnData as string[];
                for (int i = 0; i < values.Length; i++)
                {
                    Debug.WriteLine("   " + variableNames[i] + ": " + values[i]);

                    // Map the variable value results to the correct properties of File instance held by the corresponding FileReference instance.
                    fileRefForLf.File.Description = variableNames[0];
                    fileRefForLf.File.Number      = variableNames[1];
                }
            }

            return(fileRef);
        }