public override void PostAnalysis(AnalysisContext analysisContext)
        {
            HashSet <string> symbolicLinks = new HashSet <string>();

            // Find symbolic links in all VOB used
            foreach (string vob in m_vobNames)
            {
                FindSymbolicLinks(vob, symbolicLinks);
            }

            try
            {
                using (StreamWriter streamWriter = new StreamWriter(m_symbolLinkOutputFilePath, false))
                {
                    foreach (string symbolicLinkPath in symbolicLinks)
                    {
                        // Translate the symbolLinkPath to the path format used on the target side
                        try
                        {
                            string canonicalPath  = m_serverPathTranslationService.TranslateToCanonicalPathCaseSensitive(symbolicLinkPath);
                            string translatedPath = m_vcTranslationService.GetMappedPath(canonicalPath, m_sourceId);
                            streamWriter.WriteLine(translatedPath);
                        }
                        catch (Exception ex)
                        {
                            TraceManager.TraceWarning(String.Format(CultureInfo.InvariantCulture, "Unable to translate ClearCase Path '{0}': {1}",
                                                                    symbolicLinkPath, ex.ToString()));
                            TraceManager.TraceWarning(String.Format(CultureInfo.InvariantCulture, "Writing untranslated ClearCase Path to '{0}'",
                                                                    m_symbolLinkOutputFilePath));
                            streamWriter.WriteLine(symbolicLinkPath);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new MigrationException(string.Format(CultureInfo.InvariantCulture, ClearCaseSymbolicLinkMonitorAnalysisAddinResources.UnableToOpenOutputFile,
                                                           m_symbolLinkOutputFilePath, e.Message));
            }
        }
コード例 #2
0
        /// <summary>
        /// Get the information for a new label to be created on the target side of a migration/sync operation
        /// for item with a specified path.   The path format will be the same as that of the filter pair
        /// strings for the source side adapter.  The label returned is intended to be applied recursively
        /// to all items in the corresponding sub-tree on the target side.
        /// </summary>
        /// <param name="serviceContainer">A service container that provides access to services provided by the
        /// TFS Integration Platform Toolkit</param>
        /// <param name="subTreePath">The path of a sub tree being migrated (as specified a filter string)</param>
        /// <returns>An object that implements the ILabel interface</returns>
        private ILabel GetSubTreeLabel(IServiceContainer serviceContainer, string fileSystemPath)
        {
            SubTreeLabel label = null;

            try
            {
                XmlElement element = GetSemaphoreFileElement(c_label);

                if (m_vcTranslationService == null)
                {
                    // This Addin is probably configured with a WIT session; ignore any Label element that exists,
                    // but log a warning if one does.
                    if (element != null)
                    {
                        TraceManager.TraceWarning(SemaphoreFileAnalysisAddinResources.LabelInSemaphoreFileIgnored);
                    }
                }
                else
                {
                    // If the Label element is present, we will either take values from the Name and Comment
                    // attributes or will generate defaults.  If the Label element is not found, we will not
                    // add a label.
                    if (element != null && m_vcTranslationService != null)
                    {
                        string targetSideScope = m_vcTranslationService.GetMappedPath(fileSystemPath, m_sourceId);
                        label = new SubTreeLabel(fileSystemPath, targetSideScope);

                        foreach (XmlAttribute attribute in element.Attributes)
                        {
                            if (string.Equals(attribute.Name, c_name))
                            {
                                label.Name = attribute.Value;
                                if (!m_excludeDateTimeFromLabelName)
                                {
                                    label.Name += "_" + String.Format(CultureInfo.InvariantCulture, SemaphoreFileAnalysisAddinResources.DefaultLabelNameFormat,
                                                                      DateTime.Now);
                                }
                            }
                            else if (string.Equals(attribute.Name, c_comment))
                            {
                                label.Comment = attribute.Value;
                            }
                        }

                        label.LabelItems.Add(new RecursiveLabelItem(fileSystemPath));
                    }
                    else
                    {
                        TraceManager.TraceInformation(String.Format(CultureInfo.InvariantCulture,
                                                                    SemaphoreFileAnalysisAddinResources.LabelNotFoundInSemaphoreFile,
                                                                    Path.GetFullPath(m_semaphoreFilePath)));
                    }
                }
            }
            catch (Exception ex)
            {
                TraceManager.TraceWarning(String.Format(CultureInfo.InvariantCulture,
                                                        SemaphoreFileAnalysisAddinResources.ExceptionProcessingSemaphoreFile,
                                                        ex.ToString()));
            }

            return(label);
        }