当前位置: 首页>>代码示例>>C#>>正文


C# TfsTeamProjectCollection类代码示例

本文整理汇总了C#中TfsTeamProjectCollection的典型用法代码示例。如果您正苦于以下问题:C# TfsTeamProjectCollection类的具体用法?C# TfsTeamProjectCollection怎么用?C# TfsTeamProjectCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TfsTeamProjectCollection类属于命名空间,在下文中一共展示了TfsTeamProjectCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompareLocal

        /// <summary>
        /// Compares changesets
        /// </summary>
        /// <param name="localPath"></param>
        /// <param name="sourceChangesetId">Source changeset Id</param>
        /// <param name="serverUrl">Server Uri</param>
        /// <param name="srcPath">Source item path</param>
        public static void CompareLocal(string localPath, string sourceChangesetId, string serverUri, string srcPath)
        {
            if (String.IsNullOrWhiteSpace(sourceChangesetId))
                throw new ArgumentException("'sourceChangesetId' is null or empty.");
            if (String.IsNullOrWhiteSpace(serverUri))
                throw new TfsHistorySearchException("'serverUri' is null or empty.");
            if (String.IsNullOrWhiteSpace(srcPath))
                throw new TfsHistorySearchException("'srcPath' is null or empty.");
            if (String.IsNullOrWhiteSpace(localPath))
                throw new TfsHistorySearchException("'localPath' is null or empty.");

            TfsTeamProjectCollection tc = new TfsTeamProjectCollection(new Uri(serverUri));
            VersionControlServer vcs = tc.GetService(typeof(VersionControlServer)) as VersionControlServer;

            //VersionSpec sourceVersion = VersionSpec.ParseSingleSpec(sourceChangesetId, vcs.TeamFoundationServer.AuthenticatedUserName);
            VersionSpec sourceVersion = VersionSpec.ParseSingleSpec(sourceChangesetId, vcs.AuthorizedUser);

            //VersionSpec targetVersion = VersionSpec.ParseSingleSpec(targetChangesetId, vcs.TeamFoundationServer.AuthenticatedUserName);

            //Difference.DiffFiles(
            Difference.VisualDiffItems(vcs, Difference.CreateTargetDiffItem(vcs, srcPath, sourceVersion, 0, sourceVersion), Difference.CreateTargetDiffItem(vcs, localPath, null, 0, null));
            //Difference.VisualDiffFiles();
            //Difference.VisualDiffItems(vcs,
            //                           Difference.CreateTargetDiffItem(vcs, srcPath, sourceVersion, 0, sourceVersion),
            //                           Difference.CreateTargetDiffItem(vcs, targetPath, targetVersion, 0, targetVersion));
        }
开发者ID:jsvasani,项目名称:TFSHistorySearch,代码行数:33,代码来源:TfsHelper.cs

示例2: Connect

        public override void Connect(string serverUri, string remotePath, string localPath, int fromChangeset, string tfsUsername, string tfsPassword, string tfsDomain)
        {
            this._serverUri = new Uri(serverUri);
            this._remotePath = remotePath;
            this._localPath = localPath;
            this._startingChangeset = fromChangeset;

            try
            {
                NetworkCredential tfsCredential = new NetworkCredential(tfsUsername, tfsPassword, tfsDomain);
                //this._teamFoundationServer = new Microsoft.TeamFoundation.Client.TeamFoundationServer(this._serverUri, tfsCredential);
                this._tfsProjectCollection = new TfsTeamProjectCollection(this._serverUri, tfsCredential);
                this._versionControlServer = this._tfsProjectCollection.GetService<VersionControlServer>();
            }
            catch (Exception ex)
            {
                throw new Exception("Error connecting to TFS", ex);
            }

            //clear hooked eventhandlers
            BeginChangeSet = null;
            EndChangeSet = null;
            FileAdded = null;
            FileEdited = null;
            FileDeleted = null;
            FileUndeleted = null;
            FileBranched = null;
            FileRenamed = null;
            FolderAdded = null;
            FolderDeleted = null;
            FolderUndeleted = null;
            FolderBranched = null;
            FolderRenamed = null;
            ChangeSetsFound = null;
        }
开发者ID:jv42,项目名称:tfs2svn,代码行数:35,代码来源:TfsClientProvider.cs

示例3: GetLastButOneRevision

		public string GetLastButOneRevision()
		{
			var collection = new TfsTeamProjectCollection(new Uri(ConfigHelper.Instance.FuncTestCollection));
			var vcs = collection.GetService<VersionControlServer>();
			TeamProject tp = vcs.GetTeamProject(ConfigHelper.Instance.FuncTestsProject);

			var changesets = vcs.QueryHistory(
					tp.ServerItem,
					VersionSpec.Latest,
					0,
					RecursionType.Full,
					null,
					null,
					null,
					Int32.MaxValue,
					true,
					true).Cast<Changeset>().ToArray();

			collection.Dispose();

			if (changesets.Count() == 1)
				return changesets.First().ChangesetId.ToString();

			int lastButOneChangeset = changesets.Where(x => x.ChangesetId < changesets.Max(m => m.ChangesetId)).Max(x => x.ChangesetId);

			return lastButOneChangeset.ToString(CultureInfo.InvariantCulture);
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:27,代码来源:TfsFuncTestRepository.cs

示例4: ConnectToTfsCollection

        private TfsTeamProjectCollection ConnectToTfsCollection()
        {
            var tfsCredentials = GetTfsCredentials();

            foreach (var credentials in tfsCredentials)
            {
                try
                {
                    Logger.InfoFormat("Connecting to TFS {0} using {1} credentials", _config.TfsServerConfig.CollectionUri, credentials);
                    var tfsServer = new TfsTeamProjectCollection(new Uri(_config.TfsServerConfig.CollectionUri), credentials);
                    tfsServer.EnsureAuthenticated();

                    Logger.InfoFormat("Successfully connected to TFS");

                    return tfsServer;
                }
                catch (Exception ex)
                {
                    Logger.WarnFormat("TFS connection attempt failed.\n Exception: {0}", ex);
                }
            }

            Logger.ErrorFormat("All TFS connection attempts failed");
            throw new Exception("Cannot connect to TFS");
        }
开发者ID:modulexcite,项目名称:mail2bug,代码行数:25,代码来源:TFSWorkItemManager.cs

示例5: WorkItemQueryServiceModel

        public WorkItemQueryServiceModel(ITeamPilgrimServiceModelProvider teamPilgrimServiceModelProvider, ITeamPilgrimVsService teamPilgrimVsService, TfsTeamProjectCollection projectCollection, Project project)
            : base(teamPilgrimServiceModelProvider, teamPilgrimVsService)
        {
            _projectCollection = projectCollection;
            _project = project;

            QueryItems = new ObservableCollection<WorkItemQueryChildModel>();

            NewWorkItemCommand = new RelayCommand<string>(NewWorkItem, CanNewWorkItem);

            GoToWorkItemCommand = new RelayCommand(GoToWorkItem, CanGoToWorkItem);

            NewQueryDefinitionCommand = new RelayCommand<WorkItemQueryFolderModel>(NewQueryDefinition, CanNewQueryDefinition);
            NewQueryFolderCommand = new RelayCommand<WorkItemQueryFolderModel>(NewQueryFolder, CanNewQueryFolder);

            OpenQueryDefinitionCommand = new RelayCommand<WorkItemQueryDefinitionModel>(OpenQueryDefinition, CanOpenQueryDefinition);
            EditQueryDefinitionCommand = new RelayCommand<WorkItemQueryDefinitionModel>(EditQueryDefinition, CanEditQueryDefinition);

            DeleteQueryItemCommand = new RelayCommand<WorkItemQueryChildModel>(DeleteQueryDefinition, CanDeleteQueryDefinition);
            OpenSeurityDialogCommand = new RelayCommand<WorkItemQueryChildModel>(OpenSeurityDialog, CanOpenSeurityDialog);

            _populateBackgroundWorker = new BackgroundWorker();
            _populateBackgroundWorker.DoWork +=PopulateBackgroundWorkerOnDoWork;
            _populateBackgroundWorker.RunWorkerAsync();
        }
开发者ID:BruceMellows,项目名称:TeamPilgrim,代码行数:25,代码来源:WorkItemQueryServiceModel.cs

示例6: Close

        public void Close(string itemId, string comment)
        {
            using (var collection = new TfsTeamProjectCollection(locator.Location))
            {
                var workItemId = int.Parse(itemId);
                var workItemStore = new WorkItemStore(collection, WorkItemStoreFlags.BypassRules);
                var workItem = workItemStore.GetWorkItem(workItemId);
                var workItemDefinition = workItem.Store.Projects[workItem.Project.Name].WorkItemTypes[workItem.Type.Name];

                if (workItemDefinition == null)
                {
                    throw new ArgumentException("Could not obtain work item definition to close work item");
                }

                var definitionDocument = workItemDefinition.Export(false).InnerXml;
                var xDocument = XDocument.Parse(definitionDocument);
                var graphBuilder = new StateGraphBuilder();
                var stateGraph = graphBuilder.BuildStateGraph(xDocument);
                var currentStateNode = stateGraph.FindRelative(workItem.State);

                var graphWalker = new GraphWalker<string>(currentStateNode);
                var shortestWalk = graphWalker.WalkToNode("Closed");

                foreach (var step in shortestWalk.Path)
                {
                    workItem.State = step.Value;
                    workItem.Save();
                }

                workItem.Fields[CoreField.Description].Value = comment + "<br /><br/>" + workItem.Fields[CoreField.Description].Value;
                workItem.Save();
            }
        }
开发者ID:stephengodbold,项目名称:workitem-migrator,代码行数:33,代码来源:ExampleRepositoryProvider.cs

示例7: GetDropDownloadPath

        private static string GetDropDownloadPath(TfsTeamProjectCollection collection, IBuildDetail buildDetail)
        {
            string droplocation = buildDetail.DropLocation;
            if (string.IsNullOrEmpty(droplocation))
            {
                throw new FailingBuildException(string.Format(CultureInfo.CurrentCulture, "No drop is available for {0}.", buildDetail.BuildNumber));
            }

            ILocationService locationService = collection.GetService<ILocationService>();
            string containersBaseAddress = locationService.LocationForAccessMapping(ServiceInterfaces.FileContainersResource, FrameworkServiceIdentifiers.FileContainers, locationService.DefaultAccessMapping);
            droplocation = BuildContainerPath.Combine(droplocation, string.Format(CultureInfo.InvariantCulture, "{0}.zip", buildDetail.BuildNumber));

            try
            {
                long containerId;
                string itemPath;
                BuildContainerPath.GetContainerIdAndPath(droplocation, out containerId, out itemPath);

                string downloadPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}/{2}", containersBaseAddress, containerId, itemPath.TrimStart('/'));
                return downloadPath;
            }
            catch (InvalidPathException)
            {
                throw new FailingBuildException(string.Format(CultureInfo.CurrentCulture, "No drop is available for {0}.", buildDetail.BuildNumber));
            }
        }
开发者ID:modulexcite,项目名称:CustomActivities,代码行数:26,代码来源:GetDropDownloadLocation.cs

示例8: GetTestCaseParameters

        /// <summary>
        /// Get the parameters of the test case
        /// </summary>
        /// <param name="testCaseId">Test case id (work item id#) displayed into TFS</param>
        /// <returns>Returns the test case parameters in datatable format. If there are no parameters then it will return null</returns>
        public static DataTable GetTestCaseParameters(int testCaseId)
        {
            ITestManagementService TestMgrService;
            ITestCase TestCase = null;
            DataTable TestCaseParameters = null;

            NetworkCredential netCred = new NetworkCredential(
              Constants.TFS_USER_NAME,
              Constants.TFS_USER_PASSWORD);
            BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
            TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
            tfsCred.AllowInteractive = false;

            TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(
                new Uri(Constants.TFS_URL),
                tfsCred);

            teamProjectCollection.Authenticate();

            TestMgrService = teamProjectCollection.GetService<ITestManagementService>();
            TestCase = TestMgrService.GetTeamProject(Constants.TFS_PROJECT_NAME).TestCases.Find(testCaseId);

            if (TestCase != null)
            {
                if (TestCase.Data.Tables.Count > 0)
                {
                    TestCaseParameters = TestCase.Data.Tables[0];
                }
            }

            return TestCaseParameters;
        }
开发者ID:CSlatton,项目名称:hello-world,代码行数:37,代码来源:TFSActions.cs

示例9: ProcessRecord

        protected override void ProcessRecord()
        {
            using (var collection = new TfsTeamProjectCollection(CollectionUri))
            {
                var cssService = collection.GetService<ICommonStructureService4>();
                var projectInfo = cssService.GetProjectFromName(TeamProject);

                var teamService = collection.GetService<TfsTeamService>();
                var tfsTeam = teamService.ReadTeam(projectInfo.Uri, Team, null);
                if (tfsTeam == null)
                {
                    WriteError(new ErrorRecord(new ArgumentException(string.Format("Team '{0}' not found.", Team)), "", ErrorCategory.InvalidArgument, null));
                    return;
                }

                var identityService = collection.GetService<IIdentityManagementService>();
                var identity = identityService.ReadIdentity(IdentitySearchFactor.AccountName, Member, MembershipQuery.Direct, ReadIdentityOptions.None);
                if (identity == null)
                {
                    WriteError(new ErrorRecord(new ArgumentException(string.Format("Identity '{0}' not found.", Member)), "", ErrorCategory.InvalidArgument, null));
                    return;
                }

                identityService.AddMemberToApplicationGroup(tfsTeam.Identity.Descriptor, identity.Descriptor);
                WriteVerbose(string.Format("Identity '{0}' added to team '{1}'", Member, Team));
            }
        }
开发者ID:jstangroome,项目名称:PsTfsTeams,代码行数:27,代码来源:AddUserCmdlet.cs

示例10: MyTfsProjectCollection

 public MyTfsProjectCollection(CatalogNode teamProjectCollectionNode, TfsConfigurationServer tfsConfigurationServer, NetworkCredential networkCredential)
 {
     try
     {
         Name = teamProjectCollectionNode.Resource.DisplayName;
         ServiceDefinition tpcServiceDefinition = teamProjectCollectionNode.Resource.ServiceReferences["Location"];
         var configLocationService = tfsConfigurationServer.GetService<ILocationService>();
         var tpcUri = new Uri(configLocationService.LocationForCurrentConnection(tpcServiceDefinition));
         _tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcUri, new MyCredentials(networkCredential));
         _commonStructureService = _tfsTeamProjectCollection.GetService<ICommonStructureService>();
         _buildServer = _tfsTeamProjectCollection.GetService<IBuildServer>();
         _tswaClientHyperlinkService = _tfsTeamProjectCollection.GetService<TswaClientHyperlinkService>();
         CurrentUserHasAccess = true;
     }
     catch (TeamFoundationServiceUnavailableException ex)
     {
         _log.Debug("Can't access " + Name + ". This could be because the project collection is currently offline.", ex);
         CurrentUserHasAccess = false;
     }
     catch (TeamFoundationServerUnauthorizedException ex)
     {
         _log.Debug("Unauthorized access to " + teamProjectCollectionNode, ex);
         CurrentUserHasAccess = false;
     }
 }
开发者ID:jimbobTX,项目名称:SirenOfShame,代码行数:25,代码来源:MyTfsProjectCollection.cs

示例11: SetConfiguration

        public void SetConfiguration(ConfigurationBase newConfiguration)
        {
            if (timer != null)
            {
                timer.Change(Timeout.Infinite, Timeout.Infinite);
            }

            configuration = newConfiguration as TeamFoundationConfiguration;
            if (configuration == null)
            {
                throw new ApplicationException("Configuration can not be null.");
            }

            var credentialProvider = new PlainCredentialsProvider(configuration.Username, configuration.Password);

            var teamProjectCollection = new TfsTeamProjectCollection(new Uri(configuration.CollectionUri), credentialProvider);
            buildServer = teamProjectCollection.GetService<IBuildServer>();

            if (timer == null)
            {
                timer = new Timer(Tick, null, 0, configuration.PollInterval);
            }
            else
            {
                timer.Change(0, configuration.PollInterval);
            }
        }
开发者ID:chuck-n0rris,项目名称:AchtungPolizei,代码行数:27,代码来源:TeamFoundationPlugin.cs

示例12: Main

        static void Main(string[] args)
        {
            TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("https://code-inside.visualstudio.com/DefaultCollection"));

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

            //Following will get all changesets since 365 days. Note : "DateVersionSpec(DateTime.Now - TimeSpan.FromDays(20))"
            System.Collections.IEnumerable history = vcs.QueryHistory("$/Grocerylist", 
                                                                      LatestVersionSpec.Instance,
                                                                      0,
                                                                      RecursionType.Full,
                                                                      null,
                                                                      new DateVersionSpec(DateTime.Now - TimeSpan.FromDays(365)),
                                                                      LatestVersionSpec.Instance,
                                                                      Int32.MaxValue,
                                                                      true,
                                                                      false);

            foreach (Changeset changeset in history)
            {
                Console.WriteLine("Changeset Id: " + changeset.ChangesetId);
                Console.WriteLine("Owner: " + changeset.Owner);
                Console.WriteLine("Date: " + changeset.CreationDate.ToString());
                Console.WriteLine("Comment: " + changeset.Comment);
                Console.WriteLine("-------------------------------------");
            }

            Console.ReadLine();
        }
开发者ID:ledgarl,项目名称:Samples,代码行数:29,代码来源:Program.cs

示例13: GetProject

 /// <summary>
 /// Selects the target Team Project containing the migrated test cases.
 /// </summary>
 /// <param name="serverUrl">URL of TFS Instance</param>
 /// <param name="project">Name of Project within the TFS Instance</param>
 /// <returns>The Team Project</returns>
 private static ITestManagementTeamProject GetProject(string serverUrl, string project)
 {
     var uri = new System.Uri(serverUrl);
     TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(uri);
     ITestManagementService tms = tfs.GetService<ITestManagementService>();
     return tms.GetTeamProject(project);
 }
开发者ID:Ryanman,项目名称:CustomTools.AlignMigration,代码行数:13,代码来源:AlignMigration.cs

示例14: Main

        /// <summary>
        /// Main Execution. UI handled in separate method, as this is a procedural utility.
        /// </summary>
        /// <param name="args">Not used</param>
        private static void Main(string[] args)
        {
            string serverUrl, destProjectName, plansJSONPath, logPath, csvPath;
            UIMethod(out serverUrl, out destProjectName, out plansJSONPath, out logPath, out csvPath);

            teamCollection = new TfsTeamProjectCollection(new Uri(serverUrl));
            workItemStore = new WorkItemStore(teamCollection);

            Trace.Listeners.Clear();
            TextWriterTraceListener twtl = new TextWriterTraceListener(logPath);
            twtl.Name = "TextLogger";
            twtl.TraceOutputOptions = TraceOptions.ThreadId | TraceOptions.DateTime;
            ConsoleTraceListener ctl = new ConsoleTraceListener(false);
            ctl.TraceOutputOptions = TraceOptions.DateTime;
            Trace.Listeners.Add(twtl);
            Trace.Listeners.Add(ctl);
            Trace.AutoFlush = true;

            // Get Project
            ITestManagementTeamProject newTeamProject = GetProject(serverUrl, destProjectName);

            // Get Test Plans in Project
            ITestPlanCollection newTestPlans = newTeamProject.TestPlans.Query("Select * From TestPlan");

            // Inform user which Collection/Project we'll be working in
            Trace.WriteLine("Executing alignment tasks in collection \"" + teamCollection.Name 
                + "\",\n\tand Destination Team Project \"" + newTeamProject.TeamProjectName + "\"...");

            // Get and print all test case information
            GetAllTestPlanInfo(newTestPlans, plansJSONPath, logPath, csvPath);
            Console.WriteLine("Alignment completed. Check log file in:\n " + logPath 
                + "\nfor missing areas or other errors. Press enter to close.");
            Console.ReadLine();
        }
开发者ID:Ryanman,项目名称:CustomTools.AlignMigration,代码行数:38,代码来源:AlignMigration.cs

示例15: EnsureTfs

        private void EnsureTfs(bool allowCache = true)
        {
            if (_tfs != null)
                return;

            if (allowCache)
            {
                var tfsFromCache = HttpRuntime.Cache[CacheKey] as TfsTeamProjectCollection;
                if (tfsFromCache != null)
                {
                    _tfs = tfsFromCache;
                    return;
                }
            }

            lock (_CacheLock)
            {
                if (allowCache && _tfs != null)
                    return;

                _tfs = new TfsTeamProjectCollection(
                    new Uri(_principal.TfsUrl), _principal.GetCredentialsProvider());
                    //new Uri(_principal.TfsUrl), CredentialCache.DefaultCredentials, _principal.GetCredentialsProvider());

                HttpRuntime.Cache.Add(
                    CacheKey,
                    _tfs,
                    null,
                    Cache.NoAbsoluteExpiration,
                    new TimeSpan(1, 0, 0),
                    CacheItemPriority.Normal,
                    null);
            }
        }
开发者ID:ajryan,项目名称:TfsManualTester,代码行数:34,代码来源:TeamProject.cs


注:本文中的TfsTeamProjectCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。