private int GetTopDocumentInfo( string fullPath, SwDMDocument17 currentDocument, SwDMConfiguration14 currentConfig) { if (string.IsNullOrEmpty(fullPath) || currentDocument == null || currentConfig == null) { return(-1); } SldDMComponentItem root = SldDMComponentItem.GenerateTheRoot(); Task task = Task.Factory.StartNew(() => { root.FullPath = fullPath; root.FeatureName = currentDocument.Title; root.ConfigurationCount = currentDocument.GetComponentCount(); object[] subComponents = currentConfig.GetComponents(); root.ChildrenCount = subComponents == null ? 0 : subComponents.Length; if (File.Exists(fullPath)) { root.AllCustomProperties = GetDocumentPropertiesViaDM.RetrievePropertiesUnderConfig( fullPath, currentConfig, GetDocumentPropertiesViaDM.PropertyNamesOftenUsed, true); } this.ResultsAtPopulating.Enqueue(root); this.CallbackGettingExtraInfo?.Invoke(ref root); Debug.WriteLine(string.Format("GetTopDocumentInfo:got [{0}]", fullPath)); }); this.AllWalkingTasks.Enqueue(new ComponentAndTask_Assembly() { ParentId = -1, TheTask = task, FullPath = fullPath, Id = root.Id }); return(root.Id); }
protected bool TraverseCore(string assemblyPath, string configurationName) { if (string.IsNullOrEmpty(assemblyPath)) { return(false); } if (!File.Exists(assemblyPath)) { return(false); } string originalExt; SwDmDocumentType docType = SldFileExtentionChecker.CheckDM(assemblyPath, out originalExt); if (docType != SwDmDocumentType.swDmDocumentAssembly && docType != SwDmDocumentType.swDmDocumentPart) { return(false); } SwDMClassFactory swDMClassFactory = new SwDMClassFactory(); //this.AllComObjects.Enqueue(swDMClassFactory); SwDMApplication swDMApp = swDMClassFactory.GetApplication(GetDocumentPropertiesViaDM.LinktronLicenseKey); this.GlobalSearchOption = swDMApp.GetSearchOptionObject(); //this.AllComObjects.Enqueue(swDMApp); SwDmDocumentOpenError returnValue = 0; SwDMDocument17 swDoc = (SwDMDocument17)swDMApp.GetDocument(assemblyPath, docType, true, out returnValue); if (swDoc == null || returnValue != SwDmDocumentOpenError.swDmDocumentOpenErrorNone) { return(false); } //this.AllComObjects.Enqueue(swDoc); SwDMConfigurationMgr dmConfigMgr = swDoc.ConfigurationManager; //this.AllComObjects.Enqueue(dmConfigMgr); string[] configurationNames = (string[])dmConfigMgr.GetConfigurationNames(); if (configurationNames == null || configurationNames.Length <= 0) { return(false); } string configNameToOpen = null; if (string.IsNullOrEmpty(configurationName)) { configNameToOpen = dmConfigMgr.GetActiveConfigurationName(); } else { configNameToOpen = configurationName; } SwDMConfiguration14 activeCfg = (SwDMConfiguration14)dmConfigMgr.GetConfigurationByName(configNameToOpen); if (activeCfg == null) { return(false); } //this.AllComObjects.Enqueue(activeCfg); int topId = this.GetTopDocumentInfo(assemblyPath, swDoc, activeCfg); if (topId <= 0) { return(false); } if (docType == SwDmDocumentType.swDmDocumentAssembly) { try { object[] allComponents = activeCfg.GetComponents(); if (allComponents != null) { foreach (object o in allComponents) { SwDMComponent9 subComponent = o as SwDMComponent9; this.TraverseRecursively(subComponent, 1, topId); } } } catch (Exception ex) { Trace.WriteLine(string.Format("TraverseCore:exception:{0}", ex.Message)); } } return(true); }