예제 #1
0
        private void ReloadProjectContextProperties()
        {
            _reloadCounter++;
            SimpleLogger.Log(SimpleLogLevel.Info, "ReloadProjectContextProperties [" + _reloadCounter + "]");
            if (_loadFailed || _reloadCounter >= 10)
            {
                SimpleLogger.Log(SimpleLogLevel.Info, "ReloadProjectContextProperties canceled\r\n" + (new StackTrace(true)).ToString());
                return;
            }
            try
            {
                var    dte = ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
                Object obj = dte.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt");
                if (obj == null)
                {
                    SimpleLogger.Log(SimpleLogLevel.Error, "Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt not found");
                }
                Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt tfse = obj as TeamFoundationServerExt;

                if (tfse != null)
                {
                    if (tfse.ActiveProjectContext != null &&
                        tfse.ActiveProjectContext.DomainUri != null &&
                        !String.IsNullOrEmpty(tfse.ActiveProjectContext.ProjectName))
                    {
                        LoadUriAndProject(tfse);
                    }
                    else
                    {
                        WriteUnableToLoadLogEntry(tfse);
                    }
                }
                else
                {
                    SimpleLogger.Log(SimpleLogLevel.Error, "Unable to load Project Context Properties");
                    if (obj != null)
                    {
                        SimpleLogger.Log(SimpleLogLevel.Info, "was: " + obj.GetType().Namespace + "." + obj.GetType().Name);
                    }
                    _uri = null;
                    RaisePropertyChanged("Uri");
                    _project = null;
                    RaisePropertyChanged("Project");
                }
            }
            catch (Exception ex)
            {
                _loadFailed = true;
                SimpleLogger.Log(ex, false);
                _uri = null;
                RaisePropertyChanged("Uri");
                _project = null;
                RaisePropertyChanged("Project");
            }
        }
예제 #2
0
 internal VsTfsConnectionInfoProvider()
 {
     try
     {
         var dte = ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
         var obj = dte.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt");
         if (obj == null)
         {
             SimpleLogger.Log(SimpleLogLevel.Error,
                              "Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt is null");
         }
         else
         {
             Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt tfse =
                 obj as Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt;
             if (tfse != null)
             {
                 tfse.ProjectContextChanged += VsTfsProjectContextChanged;
             }
             else
             {
                 SimpleLogger.Log(SimpleLogLevel.Error,
                                  "Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt is " +
                                  obj.GetType().Namespace + "." + obj.GetType().Name + " from " +
                                  obj.GetType().AssemblyQualifiedName);
                 try
                 {
                     ((Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt)obj)
                     .ProjectContextChanged += VsTfsProjectContextChanged;
                 }
                 catch (Exception ex)
                 {
                     SimpleLogger.Log(ex, false, false);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         SimpleLogger.Log(ex, true);
     }
 }