/// <summary> /// Initializes a new instance of the <see cref="ResolverBuildResult"/> class. /// </summary> /// <param name="settings">The resolver settings.</param> public ResolverBuildResult(ISettings <ResolverValidSettings> settings) { ResolverType = "Resolver_BuildResult"; Logger.Instance().Log(TraceLevel.Info, "Initializing resolver {0} ...", ResolverType); if (settings == null) { throw new InvalidProviderConfigurationException(string.Format("Invalid connection settings were supplied")); } if (string.IsNullOrEmpty(settings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl))) { throw new InvalidProviderConfigurationException(string.Format("No team project collection url was supplied")); } if (string.IsNullOrEmpty(settings.GetSetting(ResolverValidSettings.DependencyDefinitionFileNameList))) { throw new InvalidProviderConfigurationException(string.Format("No dependency definition file name list was supplied")); } _dependencyDefinitionFileNameList = settings.GetSetting(ResolverValidSettings.DependencyDefinitionFileNameList).Split(new[] { ';' }).ToList(); ComponentTargetsName = _dependencyDefinitionFileNameList.First(); ResolverSettings = settings; // Connect to tfs server var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(settings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl))); tpc.EnsureAuthenticated(); // Connect to version control service _versionControlServer = tpc.GetService <VersionControlServer>(); if (_versionControlServer == null) { Logger.Instance().Log(TraceLevel.Error, "{0}: Could not get VersionControlServer service for {1}", ResolverType, ResolverSettings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl)); throw new InvalidProviderConfigurationException(string.Format("Could not get VersionControlServer service for {0} in {1}", ResolverSettings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl), ResolverType)); } // Connect to build server _buildServer = tpc.GetService <IBuildServer>(); if (_buildServer == null) { Logger.Instance().Log(TraceLevel.Error, "{0}: Could not get BuildServer service for {1}", ResolverType, ResolverSettings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl)); throw new InvalidProviderConfigurationException(string.Format("Could not get BuildServer service for {0} in {1}", ResolverSettings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl), ResolverType)); } Logger.Instance().Log(TraceLevel.Info, "Resolver {0} successfully initialized", ResolverType); }
public IEnumerable <Changeset> PullData(DateTime startDate, DateTime endDate) { try { VersionSpec versionFrom = new DateVersionSpec(startDate); VersionSpec versionTo = new DateVersionSpec(endDate); TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(TeamFoundationServer); VersionControlServer versionControlServer = (VersionControlServer)projectCollection.GetService(typeof(VersionControlServer)); string scope = null; if (string.IsNullOrWhiteSpace(Project)) { scope = "$/*"; } else { scope = "$/" + Project + "/"; } IEnumerable changesetHistory = versionControlServer.QueryHistory( scope, VersionSpec.Latest, 0, RecursionType.Full, null, versionFrom, versionTo, int.MaxValue, false, false); return(changesetHistory.Cast <Changeset>().ToList()); } catch (DateVersionSpecBeforeBeginningOfRepositoryException) { // Nothing to see here, moving on return(new List <Changeset>()); } catch (Exception ex) { throw new TeamFoundationException( "Unable to get versionControlServer for TFS server " + TeamFoundationServer.AbsoluteUri, ex); } }
public void Initialize(TCAdapterEnvironment env) { Trace.TraceInformation("Tfs2010WitTestCaseAdapter: Initialize BEGIN"); Trace.TraceInformation("ServerUrl: {0}", env.ServerUrl); Trace.TraceInformation("TeamProject: {0}", env.TeamProject); m_filterString = string.Empty; TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(env.ServerUrl)); WorkItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); TeamProjectName = env.TeamProject; Project = WorkItemStore.Projects[TeamProjectName]; Trace.TraceInformation("Tfs2010WitTestCaseAdapter: Initialize END"); }
public IEnumerable <WorkItem> Execute(BuildDetail earliestBuild, BuildDetail latestBuild, Uri serverUri, string projectName) { if (earliestBuild == null || latestBuild == null) { return(new WorkItem[] {}); } using (var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(serverUri)) { var builds = earliestBuild.BranchRoot.Equals(latestBuild.BranchRoot, StringComparison.InvariantCultureIgnoreCase) ? GetBuildsFromOneBranch(earliestBuild, latestBuild, projectName, collection) : GetBuildsAcrossBranches(earliestBuild, latestBuild, projectName, collection); return(GetWorkItemsForBuilds(builds, collection, projectName)); } }
public void Connect() { try { _logger.Information("Connecting to TFS."); _tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(Properties.Settings.Default.TFSUrl)); _tfsTeamProjectCollection.EnsureAuthenticated(); _versionControlServer = _tfsTeamProjectCollection.GetService <VersionControlServer>(); } catch (Exception e) { _logger.Error(e.Message); } }
public void CheckinFile(string path, string comment) { var tfsServerUri = GetTfsServerPath(path); var pc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsServerUri)); var workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(path); var workspace = workspaceInfo?.GetWorkspace(pc); var change = workspace?.GetPendingChangesEnumerable().Where(p => p.LocalItem.ToUpperEN() == path.ToUpperEN()).ToArray(); if (change?.Any() == true) { workspace.CheckIn(change.ToArray(), comment); } }
public bool CheckoutFile(string path) { var ConstTfsServerUri = GetTfsServerPath(path); using (var pc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(ConstTfsServerUri))) { if (pc == null) { return(false); } var workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(path); var workspace = workspaceInfo?.GetWorkspace(pc); return(workspace?.PendEdit(path, RecursionType.Full) == 1); } }
/// <summary> /// Queues a build, then waits for it to completed /// </summary> /// <param name="collection"></param> /// <param name="project"></param> /// <param name="buildDefinition"></param> /// <returns>Build number generated</returns> public string TriggerBuildAndWaitForCompletion(string collection, string project, string buildDefinition) { // Get the TeamFoundation Server var tfsCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(collection)); // Get the Build Server var buildServer = (IBuildServer)tfsCollection.GetService(typeof(IBuildServer)); var tfsBuildDefinition = buildServer.GetBuildDefinition(project, buildDefinition); var queuedBuild = buildServer.QueueBuild(tfsBuildDefinition); queuedBuild.WaitForBuildCompletion(TimeSpan.FromSeconds(1), TimeSpan.FromHours(1)); return(queuedBuild.Build.BuildNumber); }
/// <summary> /// Refresh version control status and update associated fields. /// </summary> /// <returns> /// Returns <c>false</c>, if no connection to a team project. /// Returns <c>false</c>, if current text document (file) not associated with version control. /// Otherwise, returns <c>true</c>. /// </returns> private bool RefreshVersionControl() { string tfsServerUriString = _tfExt.ActiveProjectContext.DomainUri; if (string.IsNullOrEmpty(tfsServerUriString)) { _versionControl = null; _versionControlItem = null; return(false); } TfsTeamProjectCollection tfsProjCollections = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsServerUriString)); _versionControl = (VersionControlServer)tfsProjCollections.GetService(typeof(VersionControlServer)); return(true); }
private WorkItemStore CreateItemStore() { //var networkCredentials = new NetworkCredential("ruslan.runchev", "December2020", "metinvest"); //var windowsCredentials = new Microsoft.VisualStudio.Services.Common.WindowsCredential(networkCredentials); //VssCredentials basicCredentials = new VssCredentials(windowsCredentials); var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(_tfsUrl)); tpc.EnsureAuthenticated(); WorkItemStore workItemStore = new WorkItemStore(tpc); return(workItemStore); }
/// <summary> /// Establishes connection with TFS and select the project and the test plan /// </summary> /// <param name="connUri">Connection URI for the TFS Server</param> /// <param name="project">TFS Project Name</param> /// <param name="planId">Test Plan ID</param> public static void InitializeVstfConnection(Uri connUri, string project, int planId) { _tempUri = connUri; TestPlanId = planId; _projectName = project; _tfsProjColl = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(_tempUri); _tfsProjColl.Authenticate(); _tms = _tfsProjColl.GetService <ITestManagementService>(); _tfsStore = (WorkItemStore)_tfsProjColl.GetService(typeof(WorkItemStore)); _teamProject = _tms.GetTeamProject(_projectName); _testPlan = _teamProject.TestPlans.Find(TestPlanId); SelectedPlanName = _testPlan.Name; }
/// <summary> /// Builds and returns the download URLs for all code coverage reports for the specified build /// </summary> public IEnumerable <string> GetCodeCoverageReportUrls(string tfsUri, string buildUri) { if (string.IsNullOrWhiteSpace(tfsUri)) { throw new ArgumentNullException(nameof(tfsUri)); } if (string.IsNullOrWhiteSpace(buildUri)) { throw new ArgumentNullException(nameof(buildUri)); } var urls = new List <string>(); logger.LogDebug(Resources.URL_DIAG_ConnectingToTfs); using (var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsUri))) { var buildServer = collection.GetService <IBuildServer>(); logger.LogDebug(Resources.URL_DIAG_FetchingBuildInfo); var build = buildServer.GetMinimalBuildDetails(new Uri(buildUri)); var projectName = build.TeamProject; logger.LogDebug(Resources.URL_DIAG_FetchingCoverageReportInfo); var tcm = collection.GetService <ITestManagementService>(); var testProject = tcm.GetTeamProject(projectName); // TODO: investigate further. It looks as if we might be requesting the coverage reports // before the service is able to provide them. // For the time being, we're retrying with a time out. IBuildCoverage[] coverages = null; Utilities.Retry(TimeoutInMs, RetryPeriodInMs, logger, () => TryGetCoverageInfo(testProject, buildUri, out coverages)); foreach (var coverage in coverages) { logger.LogDebug(Resources.URL_DIAG_CoverageReportInfo, coverage.Configuration.Id, coverage.Configuration.BuildPlatform, coverage.Configuration.BuildPlatform); var coverageFileUrl = GetCoverageUri(build, coverage); Debug.WriteLine(coverageFileUrl); urls.Add(coverageFileUrl); } } logger.LogDebug(Resources.URL_DIAG_Finished); return(urls); }
/// <summary> /// Initializes a new instance of the <see cref="DownloaderSourceControlCopy"/> class and ensures it is connected to the team project collection uri. /// </summary> /// <param name="collectionUri">The collection URI.</param> /// <param name="workspaceName">The name of the workspace.</param> /// <param name="workspaceOwner">The workspace owner.</param> public DownloaderSourceControlCopy(string collectionUri, string workspaceName, string workspaceOwner) { if (collectionUri == null) { throw new InvalidProviderConfigurationException( "Could not connect to version control on server (No collection url was provided)"); } var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(collectionUri)); tpc.EnsureAuthenticated(); _vcs = tpc.GetService <VersionControlServer>(); if (_vcs == null) { throw new InvalidProviderConfigurationException( string.Format("Could not connect to version control on server {0}", collectionUri)); } if (string.IsNullOrEmpty(workspaceName)) { throw new InvalidProviderConfigurationException( string.Format( "Could not fetch workspace information for workspace from tfs server {0} (No workspace name was provided)", collectionUri)); } if (string.IsNullOrEmpty(workspaceOwner)) { throw new InvalidProviderConfigurationException( string.Format( "Could not fetch workspace information for workspace from tfs server {0} (No workspace owner was provided)", collectionUri)); } Workstation.Current.EnsureUpdateWorkspaceInfoCache(_vcs, ".", new TimeSpan(0, 1, 0)); _workspace = _vcs.GetWorkspace(workspaceName, workspaceOwner); if (_workspace == null) { throw new InvalidProviderConfigurationException( string.Format( "Could not fetch workspace information for workspace '{0};{1}'from tfs server {2}", workspaceName, workspaceOwner, collectionUri)); } }
/// <summary> /// Initializes a new instance of the <see cref="Notification"/> class. /// </summary> /// <param name="workItemId"> /// WorkItemId of the work item to load and apply the policy on. /// </param> /// <param name="teamProjectCollectionUrl"> /// Url of Team Project Collection that holds this work item. /// </param> /// <param name="projectName"> /// The name of the project that holds this work item. /// </param> public Notification(int workItemId, ChangeTypes changeType, string teamProjectCollectionUrl, string projectName) { this.WorkItemId = workItemId; this.ChangeType = changeType; var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new System.Uri(teamProjectCollectionUrl)); var css = tpc.GetService <ICommonStructureService>(); var pi = css.ListProjects().FirstOrDefault(p => p.Name == projectName); if (pi == null) { throw new System.ApplicationException($"Project '{projectName}' not found"); } else { this.ProjectUri = pi.Uri; } }
private void LoadDefaultTFSConnection() { var setting = LoadTFSConnection(); if (setting != null) { var uri = new Uri(setting.Collection); TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri); tpc.EnsureAuthenticated(); _wiStore = (WorkItemStore)tpc.GetService(typeof(WorkItemStore)); gss = (IGroupSecurityService)tpc.GetService(typeof(IGroupSecurityService)); project = _wiStore.Projects[setting.TeamProject]; } InitProject(); }
private void buttonSearch_Click(object sender, EventArgs e) { Uri uri = new Uri(TfsUri); TeamFoundationDiscussionService service = new TeamFoundationDiscussionService(); service.Initialize(new TfsTeamProjectCollection(uri)); TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri); WorkItemStore store = projectCollection.GetService <WorkItemStore>(); WorkItemLinkInfo[] list = GetCodeReviewRequests(store); IDiscussionManager discussionManager = service.CreateDiscussionManager(); List <ResponseAnalysis> responseList = new List <ResponseAnalysis>(); List <WorkItemLinkInfo> filteredList = list.Where(p => p.SourceId != 0).ToList(); foreach (WorkItemLinkInfo item in filteredList) { ResponseAnalysis response = new ResponseAnalysis(); WorkItem Widemand = store.GetWorkItem(item.SourceId); WorkItem WiResponse = store.GetWorkItem(item.TargetId); string reviewer = WiResponse.Fields["Accepted By"].Value.ToString(); string date = Widemand.Fields["Created Date"].Value.ToString(); response.WorkiTemId = Widemand.Id; response.CommentNumber = CountComments(Widemand.Id, discussionManager, NormalizeName(reviewer)); response.OwnerName = Widemand.CreatedBy; response.CodeReviewStatus = WiResponse.Fields["Closed Status"].Value.ToString(); response.Direction = GetDirection(Widemand.CreatedBy); response.ReviewerName = reviewer; response.Team = GetTeam(Widemand.CreatedBy); //WorkItemType type = item.Links.WorkItem.Type; responseList.Add(response); } int nbConcernedLines = 0; }
static void Main() { TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("TFS_URI")); var vcS = teamProjectCollection.GetService(typeof(VersionControlServer)) as VersionControlServer; var changesets = vcS.QueryHistory("$/", VersionSpec.Latest, 0, RecursionType.Full, null, null, null, 10, true, false). Cast <Changeset>(); foreach (var changeset in changesets) { Console.WriteLine("Changes for " + changeset.ChangesetId); foreach (var change in changeset.Changes) { Console.WriteLine(change.Item.ServerItem); } } }
/// <summary> /// Initializes a new instance of the <see cref="TfsBuildHelper"/> class with a connection to the TFS server, version control and to the build server. /// </summary> /// <param name="tpcUrl">The team project collection url.</param> public TfsBuildHelper(Uri tpcUrl) { _buildServer = null; _tpcUrl = tpcUrl; if (null == _tpcUrl) { throw new ArgumentNullException("tpcUrl"); } // Connect to tfs server _tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(_tpcUrl); _tpc.EnsureAuthenticated(); // Connect to version control service & build server _versionControl = _tpc.GetService <VersionControlServer>(); _buildServer = _tpc.GetService <IBuildServer>(); }
/// <summary> /// When implemented in a derived class, performs the execution of the activity. /// </summary> /// <param name="context">The execution context under which the activity executes.</param> protected override void Execute(CodeActivityContext context) { string serverUri = context.GetValue(this.TFSCollectionUrl); int workItemID = context.GetValue(this.WorkItemID); try { var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(serverUri)); var workItemStore = collection.GetService <WorkItemStore>(); context.SetValue(this.WorkItem, workItemStore.GetWorkItem(workItemID)); LogExtensions.LogInfo(this, string.Format("Activity GetWorkItem: Workitem {0} loaded.", workItemID)); } catch (Exception ex) { throw new Exception("Activity GetWorkItem:", ex); } }
public IdentityDescriptor GetIdentityToImpersonate() { Uri server = this.GetCollectionUriFromContext(this.context); var configurationServer = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(server); // TODO: Find a way to read the identity from the server object model instead. IIdentityManagementService identityManagementService = configurationServer.GetService <IIdentityManagementService>(); Microsoft.TeamFoundation.Framework.Client.TeamFoundationIdentity identity = identityManagementService.ReadIdentities( new Guid[] { new Guid(this.Notification.ChangerTeamFoundationId) }, MembershipQuery.None).FirstOrDefault(); return(identity?.Descriptor); }
public void UndoCheckout(string filePath) { if (File.Exists(filePath)) { using (var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(this.tfsServerUrl)) { var service = tfs.GetService <VersionControlServer>(); var workspace = service.GetWorkspace(filePath); var pendingChanges = workspace.GetPendingChanges(filePath); if (pendingChanges.Count() == 1) { workspace.Undo(filePath); } } } }
private IdentityDescriptor GetIdentityToImpersonate(TeamFoundationRequestContext requestContext, WorkItemChangedEvent workItemChangedEvent) { Uri server = this.GetCollectionUriFromContext(requestContext); var configurationServer = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(server); // TODO: Find a way to read the identity from the server object model instead. IIdentityManagementService identityManagementService = configurationServer.GetService <IIdentityManagementService>(); TeamFoundationIdentity identity = identityManagementService.ReadIdentities( new Guid[] { new Guid(workItemChangedEvent.ChangerTeamFoundationId) }, MembershipQuery.None).FirstOrDefault(); return(identity?.Descriptor); }
/// <summary> /// Creates settings to use for dependency service /// </summary> /// <param name="settings">Instance to default configuration settings</param> /// <param name="componentTargetsFileName"> Name of the component.targets file</param> /// <returns></returns> private ISettings <ServiceValidSettings> CreateSettingsToUse(DependencyManagerSettings settings, string componentTargetsFileName) { var workstation = Workstation.Current; var info = workstation.GetLocalWorkspaceInfo(componentTargetsFileName); var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(info.ServerUri, new UICredentialsProvider()); if (!collection.HasAuthenticated) { collection.Authenticate(); } var workspace = info.GetWorkspace(collection); //var serverItemForLocalItem = workspace.GetServerItemForLocalItem(componentTargetsFileName); //var vcs = collection.GetService<VersionControlServer>(); var outputFolder = GetOutputFolder(workspace, componentTargetsFileName); // create settings ISettings <ServiceValidSettings> settingsToUse = new Settings <ServiceValidSettings>(); // Default TFS settings settingsToUse.AddSetting(new KeyValuePair <ServiceValidSettings, string>(ServiceValidSettings.DefaultTeamProjectCollection, collection.Uri.ToString())); settingsToUse.AddSetting(new KeyValuePair <ServiceValidSettings, string>(ServiceValidSettings.DefaultWorkspaceName, workspace.Name)); settingsToUse.AddSetting(new KeyValuePair <ServiceValidSettings, string>(ServiceValidSettings.DefaultWorkspaceOwner, workspace.OwnerName)); // Output configuration settingsToUse.AddSetting(new KeyValuePair <ServiceValidSettings, string>(ServiceValidSettings.DefaultOutputBaseFolder, outputFolder)); settingsToUse.AddSetting(new KeyValuePair <ServiceValidSettings, string>(ServiceValidSettings.DefaultRelativeOutputPath, settings.RelativeOutputPath)); // BinaryRepository settings settingsToUse.AddSetting(new KeyValuePair <ServiceValidSettings, string>(ServiceValidSettings.BinaryTeamProjectCollectionUrl, collection.Uri.ToString())); settingsToUse.AddSetting(new KeyValuePair <ServiceValidSettings, string>(ServiceValidSettings.BinaryRepositoryTeamProject, settings.BinaryRepositoryTeamProject)); // Visual Editor var dependencyDefinitionFileNameList = string.Join(";", settings.ValidDependencyDefinitionFileExtension.Select(x => string.Concat("component", x))); if (!dependencyDefinitionFileNameList.Contains(Path.GetFileName(componentTargetsFileName))) { dependencyDefinitionFileNameList = string.Concat( Path.GetFileName(componentTargetsFileName), ";", dependencyDefinitionFileNameList); } settingsToUse.AddSetting(new KeyValuePair <ServiceValidSettings, string>(ServiceValidSettings.DefaultDependencyDefinitionFilename, dependencyDefinitionFileNameList)); return(settingsToUse); }
private static void AddUsersToGroupOrTeam(string targetTeamProjectCollectionUrl, string targetTeamProject, string targetGroupOrTeam, List <User> usersToAdd) { var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(targetTeamProjectCollectionUrl)); tpc.EnsureAuthenticated(); var ims = tpc.GetService <IIdentityManagementService>(); var targetTeamName = $"[{targetTeamProject}]\\{targetGroupOrTeam}"; var tfsGroupIdentity = ims.ReadIdentity(IdentitySearchFactor.AccountName, targetTeamName, MembershipQuery.None, ReadIdentityOptions.IncludeReadFromSource); if (tfsGroupIdentity != null) { foreach (var user in usersToAdd) { var userIdentity = ims.ReadIdentity(IdentitySearchFactor.AccountName, user.AccountName, MembershipQuery.None, ReadIdentityOptions.IncludeReadFromSource); if (userIdentity != null) { try { ims.AddMemberToApplicationGroup(tfsGroupIdentity.Descriptor, userIdentity.Descriptor); Console.WriteLine($"{user.AccountName} added."); } catch (Exception ex) { Console.WriteLine($"{user.AccountName} not added: {ex.Message}"); } } else { Console.WriteLine($"{user.AccountName} not found."); } } } else { Console.WriteLine($"{targetTeamName} not found."); } }
public void Test_GetsChangeset_ForLiveServer() { var server = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://localhost:8080/tfs/defaultcollection")).GetService <VersionControlServer>(); var changeset = server.GetChangeset(100); // 73 -> 3 changes var args = new Dictionary <string, object>() { { "AssociatedChangesets", new List <Changeset>() { changeset } }, { "VersionControlServer", server } }; var merges = WorkflowInvoker.Invoke(new GetMergedChangesets(), args); Assert.AreEqual(3, merges.Count()); }
public IProjectPropertyWrapper[] GetProjectProperties(Uri projectUri) { var context = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(this.teamProjectCollectionUrl)); var ics = context.GetService <ICommonStructureService4>(); string projectName; string projectState; int templateId = 0; ProjectProperty[] projectProperties = null; ics.GetProjectProperties(projectUri.ToString(), out projectName, out projectState, out templateId, out projectProperties); return(projectProperties.Select(p => (IProjectPropertyWrapper) new ProjectPropertyWrapper() { Name = p.Name, Value = p.Value }).ToArray()); }
protected override void ProcessRecordInEH() { if (string.IsNullOrWhiteSpace(URL)) { throw new PSArgumentException("URL cannot be null or empty."); } VssCredentials creds = new VssClientCredentials(); creds.Storage = new VssClientCredentialStorage(); Uri teamCollectionURI = new Uri(URL); TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(teamCollectionURI, creds); collection.Authenticate(); WriteObject(collection); }
public void Initialize(EndPoint env) { Trace.TraceInformation("Tfs2010WitTestCaseAdapter: Initialize BEGIN"); Trace.TraceInformation("ServerUrl: {0}", env.ServerUrl); Trace.TraceInformation("TeamProject: {0}", env.TeamProject); m_filterString = string.Empty; TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(env.ServerUrl)); WorkItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); TeamProjectName = env.TeamProject; Project = WorkItemStore.Projects[TeamProjectName]; m_witQueryCount = WorkItemStore.QueryCount("SELECT [System.Id] From WorkItems"); Trace.TraceInformation("Tfs2010WitTestCaseAdapter: Initialize END"); }
public static void DeleteWorkItems(string uri, List <int> ids) { try { TfsTeamProjectCollection tfs; tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(uri)); // https://mytfs.visualstudio.com/DefaultCollection tfs.Authenticate(); var workItemStore = new WorkItemStore(tfs); workItemStore.DestroyWorkItems(ids); } catch (Exception ex) { Console.WriteLine("Error while deleting workitems " + ex.Message); } }
/// <summary> /// Покдлючиться к TFS /// </summary> public bool ConnectToTfsServer(string ServerAddress) { try { tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(ServerAddress)); structureService = (ICommonStructureService)tfsTeamProjectCollection.GetService(typeof(ICommonStructureService)); WorkItemStore wis = new WorkItemStore(ServerAddress); IProcessTemplates templates = wis.TeamProjectCollection.GetService <IProcessTemplates>(); TemplateHeader[] templateHeader = templates.TemplateHeaders(); return(true); } catch { return(false); } }