Ejemplo n.º 1
0
        private void PopulateProjectNameComboBox()
        {
            string url = tfsAddressTextBox.Text;

            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                return;
            }
            var tfs = TeamFoundationServerFactory.GetServer(url);

            tfs.EnsureAuthenticated();
            var workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

            projectComboBox.Items.Clear();
            foreach (Project project in workItemStore.Projects)
            {
                projectComboBox.Items.Add(project.Name);
            }
            int existingProjectIndex = -1;

            if (!string.IsNullOrEmpty(options.ProjectName))
            {
                existingProjectIndex = projectComboBox.Items.IndexOf(options.ProjectName);
            }
            projectComboBox.SelectedIndex = existingProjectIndex > 0 ? existingProjectIndex : 0;
        }
        static void Main(string[] args)
        {
            // Let the user choose a TFS Server.
            Console.Write("Please enter a valid TFS Server or URI: ");
            String tfsServer = Console.ReadLine();

            tfsServer = tfsServer.Trim();

            // Connect to the TeamFoundationServer.
            Console.WriteLine();
            Console.Write("Connecting to Team Foundation Server {0}...", tfsServer);
            TeamFoundationServer tfs =
                TeamFoundationServerFactory.GetServer(tfsServer);

            // Connect to the WorkItemStore.
            Console.WriteLine();
            Console.Write("Reading from the Work Item Store...");
            WorkItemStore workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

            // Display the details about the TeamFoundationServer.
            Console.WriteLine("\n");
            Console.WriteLine("Team Foundation Server details");
            Console.WriteLine("Server Name: " + tfs.Name);
            Console.WriteLine("Uri: " + tfs.Uri);
            Console.WriteLine("AuthenticatedUserDisplayName: " + tfs.AuthenticatedUserDisplayName);
            Console.WriteLine("AuthenticatedUserName: "******"WorkItemStore:");

            //  List the Projects in the WorkItemStore.
            Console.WriteLine("  Projects.Count: " + workItemStore.Projects.Count);
            foreach (Project pr in workItemStore.Projects)
            {
                Console.WriteLine("    " + pr.Name);
            }
        }
Ejemplo n.º 3
0
        internal WorkItemThingy(string srvr, string query)
        {
            _server = TeamFoundationServerFactory.GetServer(srvr);
            //_query = query;

            _store = _server.GetService(typeof(WorkItemStore)) as WorkItemStore;
        }
        static void Main(string[] args)
        {
            // Read TFS URL from the application configuration file and
            // initialize a TeamFoundationServer instance.
            var tfsUrl = ConfigurationManager.AppSettings["TfsUrl"];
            var tfs    = TeamFoundationServerFactory.GetServer(tfsUrl);

            // Get the work item tracking service that was encapsulated in a
            // WorkItemStore instance.
            var wis = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

            // Read project name form the application configuration file
            var projectName = ConfigurationManager.AppSettings["TeamProject"];


            EnsureWITImported(wis, projectName);

            var project = wis.Projects[projectName];

            var id = CreateWorkItem(project);
            var wi = GetWorkItem(wis, id);

            EditWorkItem(wi);

            QueryWorkItems(wis, projectName);

            Guid queryGuid = EnsureWIQueryCreated(wis, project);

            QueryWorkItemAsynchronously(wis, queryGuid, project);
        }
Ejemplo n.º 5
0
        private T GetService <T>()
        {
            #region Tracing
#line hidden
            if (ChangesetWatcher.m_TraceSwitch.TraceVerbose)
            {
                Trace.TraceInformation(
                    "Getting service '{0}' from server '{1}'.",
                    typeof(T),
                    Settings.Default.TeamFoundationServerUrl
                    );
            }
#line default
            #endregion

            TeamFoundationServer server = TeamFoundationServerFactory.GetServer(Settings.Default.TeamFoundationServerUrl);
            T service = (T)server.GetService(typeof(T));

            #region Tracing
#line hidden
            if (ChangesetWatcher.m_TraceSwitch.TraceVerbose)
            {
                Trace.TraceInformation(
                    "Service '{0}' successfully retrieved from server '{1}'.",
                    typeof(T),
                    Settings.Default.TeamFoundationServerUrl
                    );
            }
#line default
            #endregion

            return(service);
        }
    public bool Execute()
    {
        // set up support for logging
        TaskLoggingHelper loggingHelper = new TaskLoggingHelper(this);

        // Log Variables
        loggingHelper.LogMessageFromText("Custom Task QueueBuild Starting", MessageImportance.High);
        loggingHelper.LogMessageFromText("tfsServer = " + tfsServer, MessageImportance.High);
        loggingHelper.LogMessageFromText("teamProject = " + teamProject, MessageImportance.High);
        loggingHelper.LogMessageFromText("buildDefinition = " + buildDefinition, MessageImportance.High);
        // Get the team foundation server
        TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsServer);
        // Get the IBuildServer
        IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));
        // Get the build definition for which a build is to be queued
        IBuildDefinition buildDef = buildServer.GetBuildDefinition(teamProject, buildDefinition);
        // Create variable for queuedBuild and queue the build
        var queuedBuild = buildServer.QueueBuild(buildDef);

        loggingHelper.LogMessageFromText("Waiting for newly queued build from Team Project : " + teamProject + " : and Build Definition : " + buildDefinition + " : to complete", MessageImportance.High);
        loggingHelper.LogMessageFromText("Pinging queuedBuild : " + queuedBuild + " : every 5 seconds to confirm when build is complete", MessageImportance.High);
        // Wait for the completion of newly queued build - Will ping build every 5 seconds to confirm completion for a max of 5 hours
        queuedBuild.WaitForBuildCompletion(TimeSpan.FromSeconds(5), TimeSpan.FromHours(5));
        loggingHelper.LogMessageFromText("Queued Build : " + queuedBuild.Build.BuildNumber + " has now completed", MessageImportance.High);
        loggingHelper.LogMessageFromText("Returning to original build", MessageImportance.High);
        return(true);
    }
Ejemplo n.º 7
0
        internal static Identity ResolveUser(VSTSConnection vstsConn, string userName)
        {
            Debug.Assert(vstsConn != null, "Null vstsConn handle");
            Debug.Assert(userName != null, "Null userName param");
            if (m_gss == null)
            {
                TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(vstsConn.bisUri);
                m_gss = (IGroupSecurityService)tfs.GetService(typeof(IGroupSecurityService));
            }

            // Get the user identity
            Identity userIdentity = null;

            try
            {
                userIdentity = m_gss.ReadIdentityFromSource(SearchFactor.AccountName, userName);
            }
            catch (Exception ex)
            {
                // if there is some Active Directory issue, currently GSS throws GroupSecuritySubsystemException
                // bug#57749 plans to give specific exception for this..
                // we are handling Exception here as the bug 57749 lists this exception as well
                // as one of the possible exception that can be thrown
                // for this exception assume that the user cannot be resolved
                Logger.Write(LogSource.WorkItemTracking, TraceLevel.Warning, "Could not resolve user {0} because of {1}",
                             userName, ex.Message);
            }
            return(userIdentity);
        }
Ejemplo n.º 8
0
        public VersionControlServer GetVersionControlServer(string url)
        {
            ICredentials         creds = GetCredentials(url);
            TeamFoundationServer tfs   = TeamFoundationServerFactory.GetServer(url, creds);

            return(tfs.GetService(typeof(VersionControlServer)) as VersionControlServer);
        }
        public static ProjectInfo[] GetProjects(string collectionName)
        {
            var tfsSvrFac         = TeamFoundationServerFactory.GetServer(XML.GetCollectionURL(collectionName));
            var projectCollection = tfsSvrFac.GetService <ICommonStructureService>();

            return(projectCollection.ListAllProjects());
        }
Ejemplo n.º 10
0
        public IEnumerable <Card> GetCards(HttpRequestMessage request, string boardId)
        {
            var tfs           = TeamFoundationServerFactory.GetServer("http://your.tfs.server");
            var workItemStore = tfs.GetService <WorkItemStore>();

            var queryString = request.GetQueryNameValuePairs().ToDictionary(q => q.Key, q => q.Value, StringComparer.OrdinalIgnoreCase);
            var queryParams = new Dictionary <string, string>()
            {
                { "Iteration", @"Iteration\" + queryString["iteration"].Replace("/", "\\") }
            };

            return(workItemStore.Query(TfsQueries.Shell, queryParams).Cast <WorkItem>()
                   .Where(workItem => this.GetFieldValueOrDefault(workItem, "Microsoft.VSTS.Common.Priority", -1) >= 0)
                   .Select(workItem =>
            {
                var card = new Card();

                try
                {
                    card.Id = workItem.Id.ToString();
                    card.Title = workItem.Title;
                    card.Owner = this.GetFieldValueOrDefault(workItem, "System.AssignedTo", "<UNKNOWN>");
                    card.Priority = this.GetFieldValueOrDefault(workItem, "Microsoft.VSTS.Common.Priority", -1);
                    card.Status = this.GetCardStatus(workItem);
                }
                catch (Exception ex)
                {
                    card.Title = String.Format("ERROR: {0} - {1}", workItem.Id, ex.ToString());
                }

                return card;
            }));
        }
Ejemplo n.º 11
0
        private void initializeTfsClient()
        {
            TeamFoundationServer tfsServer = TeamFoundationServerFactory.GetServer(
                ConfigurationService.ServerUrl);

            m_tfsClient = (VersionControlServer)tfsServer.GetService(typeof(VersionControlServer));
            m_analysisServiceContainer.AddService(typeof(VersionControlServer), m_tfsClient);
        }
        private void initializeTfsClient()
        {
            TeamFoundationServer tfsServer = TeamFoundationServerFactory.GetServer(
                m_configurationService.ServerUrl);

            m_tfsClient = (VersionControlServer)tfsServer.GetService(typeof(VersionControlServer));
            m_tfsClient.NonFatalError += new ExceptionEventHandler(NonFatalError);
        }
Ejemplo n.º 13
0
        // This method returns proxy interface by the given namespace and proxy type
        internal static object GetProxy(
            string teamSystemName,      // BIS namespace
            Type proxyType)             // Type of proxy to return
        {
            TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(teamSystemName);

            return(tfs.GetService(proxyType));
        }
        /// <summary>
        /// Perform the adapter-specific initialization
        /// </summary>
        public virtual void InitializeClient(MigrationSource migrationSource)
        {
            m_migrationSource = migrationSource;
            TeamFoundationServer tfsServer = TeamFoundationServerFactory.GetServer(migrationSource.ServerUrl);

            m_tfsClient = (VersionControlServer)tfsServer.GetService(typeof(VersionControlServer));
            m_tfsClient.NonFatalError += new ExceptionEventHandler(NonFatalError);
        }
        /// <summary>
        /// Perform the adapter-specific initialization
        /// </summary>
        public virtual void InitializeClient(MigrationSource migrationSource)
        {
            TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(migrationSource.ServerUrl);

            tfs.Authenticate();

            m_workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

            m_projectName = migrationSource.SourceIdentifier;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// This method is called when the plug-in is loaded for the fist
        /// time.
        /// </summary>
        /// <param name="ds">An IDataStore instance.</param>
        public void Initialize(IDataStore ds)
        {
            m_dataStore = ds;

            var tfs = TeamFoundationServerFactory.GetServer(
                TeamFoundationApplication.TfsNameUrl);

            m_commonStructureService = (ICommonStructureService)
                                       tfs.GetService(typeof(ICommonStructureService));
        }
Ejemplo n.º 17
0
 public void LoadPrefs()
 {
     _registredServers.Clear();
     if (!File.Exists(ConfigFile))
     {
         return;
     }
     try
     {
         using (var file = File.OpenRead(ConfigFile))
         {
             XDocument doc = XDocument.Load(file);
             foreach (var serverElement in doc.Root.Element("Servers").Elements("Server"))
             {
                 var isPasswordSavedInXml = serverElement.Attribute("Password") != null;
                 var password             = isPasswordSavedInXml ? serverElement.Attribute("Password").Value : CredentialsManager.GetPassword(new Uri(serverElement.Attribute("Url").Value));
                 if (password == null)
                 {
                     throw new Exception("TFS Addin: No Password found for TFS server: " + serverElement.Attribute("Name").Value);
                 }
                 var server = TeamFoundationServerFactory.Create(serverElement, password, isPasswordSavedInXml);
                 if (server != null)
                 {
                     _registredServers.Add(server);
                 }
             }
             foreach (var workspace in doc.Root.Element("Workspaces").Elements("Workspace"))
             {
                 _activeWorkspaces.Add(workspace.Attribute("Id").Value, workspace.Attribute("Name").Value);
             }
             var mergeToolElement = doc.Root.Element("MergeTool");
             if (mergeToolElement != null)
             {
                 this.MergeToolInfo = new MergeToolInfo
                 {
                     CommandName = mergeToolElement.Attribute("Command").Value,
                     Arguments   = mergeToolElement.Attribute("Arguments").Value,
                 };
             }
             checkOutLockLevel = doc.Root.Element("CheckOutLockLevel") == null ? CheckOutLockLevel.Unchanged : (CheckOutLockLevel)Convert.ToInt32(doc.Root.Element("CheckOutLockLevel").Value);
             isDebugMode       = doc.Root.Element("DebugMode") != null && Convert.ToBoolean(doc.Root.Element("DebugMode").Value);
             this.Servers.ForEach(s => s.IsDebuMode = isDebugMode);
             file.Close();
         }
     }
     catch (Exception e)
     {
         MessageService.ShowException(e);
         return;
     }
     if (_registredServers.Any())
     {
         RaiseServersChange();
     }
 }
Ejemplo n.º 18
0
        public override bool Execute()
        {
            Server    = ""; //TODO: Fill the TFS Server
            Root      = @"$/DotNetNuke/src/DotNetNuke_CS/";
            Committer = ""; //TODO: Fill the committer username.

#pragma warning disable 612,618
            TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(Server);
#pragma warning restore 612,618
            var vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

            string              path                = Root;
            VersionSpec         version             = VersionSpec.Latest;
            const int           deletionId          = 0;
            const RecursionType recursion           = RecursionType.Full;
            string              user                = null;
            VersionSpec         versionFrom         = null;
            VersionSpec         versionTo           = null;
            const int           maxCount            = 100;
            const bool          includeChanges      = true;
            const bool          slotMode            = true;
            const bool          includeDownloadInfo = true;

            IEnumerable enumerable =
                vcs.QueryHistory(path,
                                 version,
                                 deletionId,
                                 recursion,
                                 user,
                                 versionFrom,
                                 versionTo,
                                 maxCount,
                                 includeChanges,
                                 slotMode,
                                 includeDownloadInfo);


            var c = new List <Changeset>();

            foreach (var i in enumerable)
            {
                var cs = (i as Changeset);
                if (cs != null && cs.Committer != Committer)
                {
                    foreach (var change in cs.Changes)
                    {
                        if (!change.Item.ServerItem.Contains("Professional"))
                        {
                            c.Add(cs);
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Internal helper method to get the service
        /// </summary>
        /// <typeparam name="T">Type of service to retrieve</typeparam>
        /// <param name="credentials">Credentials to use when connecting the service</param>
        /// <returns></returns>
        private static T GetService <T>(ICredentials credentials)
        {
            TempCredentials creds = new TempCredentials(credentials);
            string          teamFoundationServerUrl = Settings.Default.TeamFoundationServerUrl;

            TraceHelper.TraceVerbose(Constants.CommonSwitch, "Connecting to server {0} To get service {1} ", teamFoundationServerUrl, typeof(T).ToString());
            TeamFoundationServer server = TeamFoundationServerFactory.GetServer(teamFoundationServerUrl, creds);
            T service = (T)server.GetService(typeof(T));

            return(service);
        }
Ejemplo n.º 20
0
        public static TeamFoundationServer GetTfsServer(string tfsServerName)
        {
            var teamFoundationServer = TeamFoundationServerFactory.GetServer(tfsServerName);

            if (!teamFoundationServer.HasAuthenticated)
            {
                teamFoundationServer.Authenticate();
            }

            return(teamFoundationServer);
        }
Ejemplo n.º 21
0
        public void ConnectToTfsServer(string hostname, string teamCollection, string projectName, string buildDefinitionName = null)
        {
            _hostname       = hostname;
            _teamCollection = teamCollection;
            _projectName    = projectName;

            _isWebServer = _hostname.Contains("://");

            try
            {
                string url;
                if (_isWebServer)
                {
                    _hostname = _hostname.TrimEnd('\\', '/');
                    url       = _hostname + "/" + teamCollection;
                }
                else
                {
                    url = "http://" + _hostname + ":8080/tfs/" + teamCollection;
                }

                // Get a connection to the desired Team Foundation Server
                var tfServer = TeamFoundationServerFactory.GetServer(url, new UICredentialsProvider());

                // Get a reference to a build service
                var buildServer = tfServer.GetService <IBuildServer>();

                // Retrieve a list of build definitions
                var buildDefs = buildServer.QueryBuildDefinitions(projectName);

                if (buildDefs.Length != 0)
                {
                    if (string.IsNullOrWhiteSpace(buildDefinitionName))
                    {
                        _buildDefinition = buildDefs[0];
                    }
                    else
                    {
                        foreach (var buildDefinition in buildDefs)
                        {
                            if (string.Compare(buildDefinition.Name, buildDefinitionName, true) == 0)
                            {
                                _buildDefinition = buildDefinition;
                                return;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 22
0
        static public WorkItemCollection QueryWorkItems(string server, string projectname)
        {
            TeamFoundationServer tfs           = TeamFoundationServerFactory.GetServer(server);
            WorkItemStore        workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
            Project p         = workItemStore.Projects[projectname];
            string  wiqlQuery = "Select * from Issue where [System.TeamProject] = '" + projectname + "'";

            wiqlQuery += " and [System.State] <> 'Deleted'";
            wiqlQuery += " order by ID";
            WorkItemCollection witCollection = workItemStore.Query(wiqlQuery);

            return(witCollection);
        }
Ejemplo n.º 23
0
        private static WorkItemType GetWorkItemType(string serverName, string teamProjectName, string witName)
        {
            string serverUrl = string.Format("http://{0}:8080", serverName);

            TeamFoundationServer tfsServer = TeamFoundationServerFactory.GetServer(serverUrl);
            WorkItemStore        wis       = (WorkItemStore)tfsServer.GetService(typeof(WorkItemStore));

            Project project = wis.Projects[teamProjectName];

            Debug.Assert(project != null);

            return(project.WorkItemTypes[witName]);
        }
        private void PopulateProjects()
        {
            TeamProjectDropDown.Items.Clear();
            TeamFoundationServer    tfs = TeamFoundationServerFactory.GetServer(lblServerUri.Text);
            ICommonStructureService projectCollection =
                (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService));

            foreach (ProjectInfo projectInfo in projectCollection.ListProjects())
            {
                TeamProjectDropDown.Items.Add(projectInfo.Name);
            }
            TeamProjectDropDown.Enabled = true;
        }
Ejemplo n.º 25
0
        private void GetChangesetsAsync(object sender, DoWorkEventArgs e)
        {
            changesetsForWeek.Clear();

            TeamFoundationServer tfs = null;

            try
            {
                var optionsVM    = ViewModelLocater.OptionsViewModel;
                var mainWindowVM = ViewModelLocater.MainWindowViewModel;

                if (optionsVM.SpecifyUserCredentials && optionsVM.CredentialsAreValid)
                {
                    NetworkCredential cred = new NetworkCredential(optionsVM.Username, optionsVM.Password, optionsVM.Domain);
                    tfs = new TeamFoundationServer(ConfigManager.TfsServerUrl + "/" + ConfigManager.TfsCollectionName, cred);
                }
                else
                {
                    tfs = TeamFoundationServerFactory.GetServer(ConfigManager.TfsServerUrl + "/" + ConfigManager.TfsCollectionName);
                }

                tfs.EnsureAuthenticated();

                VersionControlServer vcServer = tfs.GetService <VersionControlServer>();
                string projectPath            = vcServer.GetTeamProject(ConfigManager.TfsProjectName).ServerItem;

                changesetsForWeek = vcServer.QueryHistory(projectPath,
                                                          VersionSpec.Latest,
                                                          0,
                                                          RecursionType.Full,
                                                          mainWindowVM.CurrentUser,
                                                          null,
                                                          null,
                                                          ConfigManager.MaxCheckinsPerQuery,
                                                          true,
                                                          false).Cast <Changeset>()
                                    .Where(
                    cs =>
                    cs.CreationDate.Date >= mainWindowVM.SelectedWeek.StartOfWeek.Date &&
                    cs.CreationDate.Date <= mainWindowVM.SelectedWeek.EndOfWeek.Date)
                                    .Select(cs => new ChangesetModel(cs))
                                    .ToList();
            }
            finally
            {
                if (tfs != null)
                {
                    tfs.Dispose();
                }
            }
        }
Ejemplo n.º 26
0
        protected override void PopulateRowChildren(TreeIter iter)
        {
            string path = store.GetValue(iter, ColumnIndex.Path).ToString();

            string    url       = String.Empty;
            Workspace workspace = null;

            TreeIter iterParent; TreeIter current = iter;

            while (store.IterParent(out iterParent, current))
            {
                current = iterParent;
            }

            url       = store.GetValue(current, ColumnIndex.Url).ToString();
            workspace = store.GetValue(current, ColumnIndex.Workspace) as Workspace;

            ICredentials         credentials          = credentialsProvider.GetCredentials(new Uri(url), null);
            TeamFoundationServer tfs                  = TeamFoundationServerFactory.GetServer(url, credentials);
            VersionControlServer versionControlServer = tfs.GetService(typeof(VersionControlServer)) as VersionControlServer;

            int      indx     = 0;
            ItemSpec itemSpec = new ItemSpec(path, RecursionType.OneLevel);
            ItemSet  itemSet  = versionControlServer.GetItems(itemSpec, VersionSpec.Latest,
                                                              DeletedState.NonDeleted, ItemType.Folder, false);

            foreach (Microsoft.TeamFoundation.VersionControl.Client.Item item in itemSet.Items)
            {
                if (item.ServerItem == path)
                {
                    continue;
                }

                string shortPath = item.ServerItem.Substring(item.ServerItem.LastIndexOf('/') + 1);
                bool   mapped    = workspace.IsServerPathMapped(item.ServerItem);

                Gtk.TreeIter child = SetRowValue(store, iter, indx, Images.Folder, shortPath,
                                                 url, item.ServerItem, workspace, mapped);
                store.AppendValues(child, null, "", "", "", null, true);

                indx++;
            }

            // we didn't add anything!
            if (indx == 0)
            {
                TreeIter citer; store.IterChildren(out citer, iter);
                store.Remove(ref citer);
            }
        }
Ejemplo n.º 27
0
        void m_worker_DoWork(object sender, DoWorkEventArgs e)
        {
            TeamFoundationServer collection = TeamFoundationServerFactory.GetServer(m_migrationSource.ServerUrl);

            WorkItemStore store = collection.GetService(typeof(WorkItemStore)) as WorkItemStore;

            foreach (Project project in store.Projects)
            {
                if (string.Equals(project.Name, m_migrationSource.SourceIdentifier))
                {
                    m_project = project;
                }
            }

            e.Result = new WITQueryNodeViewModel(m_project.StoredQueries, m_project.Name);
        }
Ejemplo n.º 28
0
        private Scenario[] GetScenariosForQuery(string query)
        {
            var server = TeamFoundationServerFactory.GetServer(serverName);
            var store  = (WorkItemStore)server.GetService(typeof(WorkItemStore));

            var workItems = store.Query(query);

            var result = new List <Scenario>();

            foreach (WorkItem workItem in workItems)
            {
                var scenario = new Scenario(workItem.Id, workItem.Title, workItem.Description);
                result.Add(scenario);
            }

            return(result.ToArray());
        }
Ejemplo n.º 29
0
        private void GetPathAndScope(string szFile,
                                     out VersionControlServer sourceControl,
                                     out Workspace workspace)
        {
            // Figure out the server based on either the argument or the
            // current directory.
            WorkspaceInfo wsInfo = null;

            workspace = null;
            if (!VersionControlPath.IsServerItem(szFile))
            {
                wsInfo = Workstation.Current.GetLocalWorkspaceInfo(szFile);
            }

            TeamFoundationServer tfs = null;

            if (wsInfo == null)
            {
                wsInfo = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory);
            }

            if (wsInfo != null)
            {
                //Just in case our local file is hooked to a different server
                m_szServerAddress = wsInfo.ServerUri.AbsoluteUri;
            }

            tfs = TeamFoundationServerFactory.GetServer(m_szServerAddress);

            sourceControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

            // Pick up the label scope, if supplied.
            string scope = VersionControlPath.RootFolder;

            // The scope must be a server path, so we convert it here if
            // the user specified a local path.
            if (!VersionControlPath.IsServerItem(szFile))
            {
                workspace = wsInfo.GetWorkspace(tfs);
                scope     = workspace.GetServerItemForLocalItem(szFile);
            }
            else
            {
                scope = szFile;
            }
        }
Ejemplo n.º 30
0
        private void InitializeTfsClient()
        {
            TeamFoundationServer tfsServer = TeamFoundationServerFactory.GetServer(m_configurationService.ServerUrl);

            m_tfsClient = tfsServer.GetService(typeof(VersionControlServer)) as VersionControlServer;

            MigrationSource migrationSourceConfiguration = m_configurationService.MigrationSource;

            Debug.Assert(null != migrationSourceConfiguration, "cannot get MigrationSource config from Session");

            TfsMigrationDataSource            dataSourceConfig = InitializeMigrationDataSource();
            ReadOnlyCollection <MappingEntry> filters          = m_configurationService.Filters;

            // Allow multiple filter strings from other adapters
            // Debug.Assert(filters.Count == 1, "filters.Count != 1 for WIT migration source");
            dataSourceConfig.Filter     = filters[0].Path;
            dataSourceConfig.ServerId   = migrationSourceConfiguration.ServerIdentifier;
            dataSourceConfig.ServerName = migrationSourceConfiguration.ServerUrl;
            dataSourceConfig.Project    = migrationSourceConfiguration.SourceIdentifier;

            m_migrationSource = new TfsWITMigrationSource(
                migrationSourceConfiguration.InternalUniqueId,
                dataSourceConfig.CreateWorkItemStore());
            m_migrationSource.WorkItemStore.ServiceContainer = this.m_serviceContainer;

            foreach (CustomSetting setting in migrationSourceConfiguration.CustomSettings.CustomSetting)
            {
                if (setting.SettingKey.Equals(TfsConstants.DisableAreaPathAutoCreation, StringComparison.InvariantCultureIgnoreCase))
                {
                    m_migrationSource.WorkItemStore.Core.DisableAreaPathAutoCreation =
                        TfsWITCustomSetting.GetBooleanSettingValueDefaultToTrue(setting);
                }
                else if (setting.SettingKey.Equals(TfsConstants.DisableIterationPathAutoCreation, StringComparison.InvariantCultureIgnoreCase))
                {
                    m_migrationSource.WorkItemStore.Core.DisableIterationPathAutoCreation =
                        TfsWITCustomSetting.GetBooleanSettingValueDefaultToTrue(setting);
                }
                else if (setting.SettingKey.Equals(TfsConstants.EnableBypassRuleDataSubmission, StringComparison.InvariantCultureIgnoreCase))
                {
                    m_migrationSource.WorkItemStore.ByPassrules =
                        TfsWITCustomSetting.GetBooleanSettingValueDefaultToTrue(setting);
                }
            }
        }