/// <summary> /// Find those Task Assistant workbooks in the database that are not being used by /// any step that launches ArcMap /// </summary> /// <returns>The total number of orphaned items found</returns> private int UpdateOrphanedTaWorkbooks() { SortedList <string, string> unusedItems = new SortedList <string, string>(); IJTXDatabase3 wmxDb = this.WmxDatabase; IJTXConfiguration3 configMgr = wmxDb.ConfigurationManager as IJTXConfiguration3; IJTXTaskAssistantWorkflowRecordSet allItems = configMgr.TaskAssistantWorkflowRecords; // First check to see if there are even any TA workbooks in the database if (allItems.Count > 0) { Dictionary <string, string> usedTypes = new Dictionary <string, string>(); // Search all the step types for Task Assistant workbooks currently in use IJTXStepTypeSet allStepTypes = wmxDb.ConfigurationManager.StepTypes; for (int i = 0; i < allStepTypes.Count; i++) { IJTXStepType2 stepType = allStepTypes.get_Item(i) as IJTXStepType2; // Skip over unused step types if (m_unusedStepTypes.Keys.Contains(stepType.ID)) { continue; } // Examine the remaining step types for (int j = 0; j < stepType.Arguments.Length; j++) { string stepArg = stepType.Arguments[j].ToString(); if (stepArg.StartsWith(C_WORKBOOK_FLAG)) { string suffix = stepArg.Substring(C_WORKBOOK_FLAG.Length); suffix = suffix.Trim(new char[] { '"' }); usedTypes[suffix] = null; } } } // Loop over all the Task Assistant workbooks, looking for anything // that we didn't identify as "in use" for (int i = 0; i < allItems.Count; i++) { IJTXTaskAssistantWorkflowRecord item = allItems.get_Item(i); if (!usedTypes.ContainsKey(item.Alias)) { m_unusedTaWorkbooks[item.Alias] = null; } } } return(m_unusedTaWorkbooks.Count); }
/// <summary> /// Gets a list of all the TAM workbooks that are stored in the current WMX database /// </summary> /// <returns>A sorted list of the TAM workbooks</returns> private SortedList <string, string> ListTamWorkbooksInDatabase() { SortedList <string, string> tamWorkbookNames = new SortedList <string, string>(); IJTXConfiguration3 configMgr = WmxDatabase.ConfigurationManager as IJTXConfiguration3; IJTXTaskAssistantWorkflowRecordSet tamWorkbooks = configMgr.TaskAssistantWorkflowRecords; for (int i = 0; i < tamWorkbooks.Count; i++) { IJTXTaskAssistantWorkflowRecord tamWorkbook = tamWorkbooks.get_Item(i); tamWorkbookNames.Add(tamWorkbook.Alias, null); } return(tamWorkbookNames); }
/// <summary> /// Builds a domain containing the names of all the task assistant /// workbooks embedded in the database /// </summary> /// <param name="wmxDb">A reference to the active Workflow Manager database</param> /// <returns>A coded value domain as an IGPDomain</returns> public static IGPDomain BuildTamWorkbookDomain(IJTXDatabase3 wmxDb) { IGPCodedValueDomain tamNames = new GPCodedValueDomainClass(); SortedList <string, string> sortedTamNames = new SortedList <string, string>(); IJTXConfiguration3 configMgr = wmxDb.ConfigurationManager as IJTXConfiguration3; IJTXTaskAssistantWorkflowRecordSet tamWorkbooks = configMgr.TaskAssistantWorkflowRecords; for (int i = 0; i < tamWorkbooks.Count; i++) { IJTXTaskAssistantWorkflowRecord tamWorkbook = tamWorkbooks.get_Item(i); sortedTamNames.Add(tamWorkbook.Alias, null); } foreach (string tamName in sortedTamNames.Keys) { tamNames.AddStringCode(tamName, tamName); } return(tamNames as IGPDomain); }