public OptionsForm(TfsSettings settings) { InitializeComponent(); this.settings = settings; if (!String.IsNullOrEmpty(settings.TeamServer)) { TFS = new TeamFoundationServer(settings.TeamServer); TFS.EnsureAuthenticated(); if (!String.IsNullOrEmpty(settings.TeamProject)) { TeamProject = settings.TeamProject; if (!String.IsNullOrEmpty(settings.WorkItemType)) { cmbWorkItemType.Enabled = true; cmbWorkItemType.SelectedItem = settings.WorkItemType; } } } txtDefaultImageName.Text = settings.DefaultImageName; cmbImageFormat.SelectedItem = settings.DefaultImageFormat; txtDefaultAttachmentComment.Text = settings.DefaultAttachmentComment; txtImageEditor.Text = settings.ImageEditor; cbOpenImageInEditor.Checked = settings.OpenImageInEditor; SelectedImageFormatChanged(null, null); HandleQualitySliderValueChanged(null, null); }
public void Workspace_GetViaInfo() { // need TFS_ envvars for this test if (String.IsNullOrEmpty(tfsUrl)) { return; } TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); WorkingFolder[] folders = new WorkingFolder[1]; string serverItem = String.Format("$/{0}", Environment.GetEnvironmentVariable("TFS_PROJECT")); folders[0] = new WorkingFolder(serverItem, Environment.CurrentDirectory); Workspace w1 = vcs.CreateWorkspace("CreateDelete1_Workspace", Environment.GetEnvironmentVariable("TFS_USERNAME"), "My Comment", folders, Environment.MachineName); //Workstation.Current.UpdateWorkspaceInfoCache(vcs, Environment.GetEnvironmentVariable("TFS_USERNAME")); WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory); Workspace w2 = info.GetWorkspace(tfs); // does info.GetWorkspace talk to the server and get the // mapped paths or no? ANSWER: NO IT DOESN'T string serverItem2 = w2.TryGetServerItemForLocalItem("foo.txt"); Assert.AreEqual(null, serverItem2); w1.Delete(); }
/// <summary> /// Tries the TFS mode. /// </summary> /// <param name="input">The input.</param> /// <returns>the number of checkedout files</returns> internal static int TryTFSMode(System.IO.FileInfo input) { try { var tfs = new TeamFoundationServer(Properties.Settings.Default.TFSServer, new NetworkCredential(Properties.Settings.Default.TFSLogin, Properties.Settings.Default.TFSPassword)); var version = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); var workspace = version.GetWorkspace(Properties.Settings.Default.TFSWorkspace, version.AuthorizedUser); int ans = workspace.PendEdit(input.FullName); return(ans); } catch (Exception) { Console.WriteLine( string.Format( @" /!\The file {0} is read only please make sure the TFS app settings are OK Stack trace: ", input.FullName)); throw; } }
public VersionControlServer GetVersionControlServer(string url) { ICredentials creds = GetCredentials(url); TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(url, creds); return(tfs.GetService(typeof(VersionControlServer)) as VersionControlServer); }
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); } }
/// <summary> /// Performs the action of this task. /// </summary> protected override void InternalExecute() { using (this.tfs = new TeamFoundationServer(this.TeamFoundationServerUrl)) { this.buildServer = (IBuildServer)this.tfs.GetService(typeof(IBuildServer)); switch (this.TaskAction) { case GetLatestTaskAction: this.GetLatestInfo(); break; case RelatedChangesetsTaskAction: this.RelatedChangesets(); break; case RelatedWorkItemsTaskAction: this.RelatedWorkItems(); break; case QueueTaskAction: this.QueueBuild(); break; default: this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Invalid TaskAction passed: {0}", this.TaskAction)); return; } } }
public static VSTSMonitor GetMonitor(TeamFoundationServer server, string stateFilePath, string projectPath, int port) { VSTSMonitor Monitor = null; try { lock (SyncLock) { if (Monitors.ContainsKey(projectPath)) { return(Monitors[projectPath]); } Monitor = new VSTSMonitor(server, stateFilePath, projectPath, port); Monitors.Add(projectPath, Monitor); } } catch (System.Exception ex) { ThoughtWorks.CruiseControl.Core.Util.Log.Error(ex); throw; } return(Monitor); }
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); }
public AttachDialog(TfsSettings settings, TeamFoundationServer tfs) { InitializeComponent(); this.settings = settings; if (tfs != null) { this.TFS = tfs; } else { if (!String.IsNullOrEmpty(settings.TeamServer)) { TFS = new TeamFoundationServer( settings.TeamServer); TFS.EnsureAuthenticated(); } } if (!String.IsNullOrEmpty(settings.TeamProject)) { TeamProject = settings.TeamProject; if (!String.IsNullOrEmpty(settings.WorkItemType)) { cmbWorkItemType.Enabled = true; cmbWorkItemType.SelectedItem = settings.WorkItemType; } } txtImageName.Text = settings.DefaultImageName; txtAttachmentComment.Text = settings.DefaultAttachmentComment; txtImageEditor.Text = settings.ImageEditor; cbOpenImageInEditor.Checked = settings.OpenImageInEditor; }
private bool ChooseProject() { // The domain picker is a user control in the Team Foundation OM // for selecting a Team Foundation Server and Team Project. DomainProjectPicker domainPicker = new DomainProjectPicker(DomainProjectPickerMode.AllowProjectSelect); if (m_tfs != null) { domainPicker.SelectedServer = m_tfs; } if (domainPicker.ShowDialog() == DialogResult.OK) { m_teamProject = null; m_tfs = domainPicker.SelectedServer; ProjectInfo[] projects = domainPicker.SelectedProjects; if (projects.Length > 0) { m_teamProject = projects[0]; } return(true); } else { m_teamProject = null; return(false); } }
private void button2_Click(object sender, System.EventArgs e) { //Configure credentials ICredentials credentials = new NetworkCredential(this.txtLogin.Text, this.txtPassword.Text, this.txtDomain.Text); //Create the team foundation server class TeamFoundationServer teamFoundationServer = new TeamFoundationServer("http://inflectrasvr03:8080/", credentials); //Get access to the work item store WorkItemStore workItemStore = new WorkItemStore(teamFoundationServer); try { //Create the new work item Project project = workItemStore.Projects["Library Information System"]; WorkItemType workItemType = project.WorkItemTypes["Bug"]; WorkItem workItem = new WorkItem(workItemType); //workItem.AreaId = 1; workItem.Title = "SpiraTest Imported bug"; workItem.Description = "Test description from SpiraTest"; workItem.State = "Active"; workItem.Reason = "New"; workItem["Issue"] = "No"; //workItem[CoreField.CreatedBy] = "Administrator"; //workItem[CoreField.ChangedDate] = DateTime.Now; workItem.Save(); this.textBox1.Text = workItem.Id.ToString(); } catch (Exception exception) { this.textBox1.Text = exception.Message + "\nStack Trace:\n" + exception.StackTrace; } }
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); }
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 void FixtureSetUp() { tfsUrl = Environment.GetEnvironmentVariable("TFS_URL"); if (String.IsNullOrEmpty(tfsUrl)) { Console.WriteLine("Warning: Environment variable TFS_URL not set."); Console.WriteLine(" Some tests cannot be executed without TFS_URL."); return; } string username = Environment.GetEnvironmentVariable("TFS_USERNAME"); if (String.IsNullOrEmpty(username)) { Console.WriteLine("Warning: No TFS user credentials specified."); return; } credentials = new NetworkCredential(username, Environment.GetEnvironmentVariable("TFS_PASSWORD"), Environment.GetEnvironmentVariable("TFS_DOMAIN")); // need TFS_ envvars for this test if (String.IsNullOrEmpty(tfsUrl)) { return; } TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); versionControlServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); workspace = versionControlServer.CreateWorkspace("WorkspaceTest", Environment.GetEnvironmentVariable("TFS_USERNAME")); }
public void ConnectTfs() { var tfs = new TeamFoundationServer("http://tfsny:8080/tfs"); tfs.Authenticate(); WorkItems = new WorkItemStore(tfs); }
internal WorkItemThingy(string srvr, string query) { _server = TeamFoundationServerFactory.GetServer(srvr); //_query = query; _store = _server.GetService(typeof(WorkItemStore)) as WorkItemStore; }
public void Workspace_Get() { // need TFS_ envvars for this test if (String.IsNullOrEmpty(tfsUrl)) { return; } TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); WorkingFolder[] folders = new WorkingFolder[1]; string serverItem = String.Format("$/{0}", Environment.GetEnvironmentVariable("TFS_PROJECT")); folders[0] = new WorkingFolder(serverItem, Environment.CurrentDirectory); Workspace w1 = vcs.CreateWorkspace("CreateDelete1_Workspace", Environment.GetEnvironmentVariable("TFS_USERNAME"), "My Comment", folders, Environment.MachineName); Workspace w2 = vcs.GetWorkspace("CreateDelete1_Workspace"); Assert.AreEqual("My Comment", w2.Comment); w1.Delete(); }
public void Workspace_RefreshMappings2() { // need TFS_ envvars for this test if (String.IsNullOrEmpty(tfsUrl)) { return; } TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); WorkingFolder[] folders = new WorkingFolder[1]; string serverItem = String.Format("$/{0}", Environment.GetEnvironmentVariable("TFS_PROJECT")); folders[0] = new WorkingFolder(serverItem, Environment.CurrentDirectory); Workspace w1 = vcs.CreateWorkspace("CreateDelete1_Workspace", Environment.GetEnvironmentVariable("TFS_USERNAME"), "My Comment", folders, Environment.MachineName); //Workstation.Current.UpdateWorkspaceInfoCache(vcs, Environment.GetEnvironmentVariable("TFS_USERNAME")); WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory); Workspace w2 = info.GetWorkspace(tfs); // this will talk to the server and get the mapped paths // BUT it will fail because we don't pass a full path like in RefreshMappings1 w2.RefreshMappings(); string serverItem2 = w2.TryGetServerItemForLocalItem("foo.txt"); Assert.IsNull(serverItem2); w1.Delete(); }
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 SetWorkItemType() { _tfs = new TeamFoundationServer(_settings.TeamServer); _tfs.EnsureAuthenticated(); _wis = _tfs.GetService(typeof(WorkItemStore)) as WorkItemStore; SelectedWorkItemType = _wis.Projects[_settings.TeamProject] .WorkItemTypes[_settings.WorkItemType]; }
private void initializeTfsClient() { TeamFoundationServer tfsServer = TeamFoundationServerFactory.GetServer( m_configurationService.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) { m_migrationSource = migrationSource; TeamFoundationServer tfsServer = TeamFoundationServerFactory.GetServer(migrationSource.ServerUrl); m_tfsClient = (VersionControlServer)tfsServer.GetService(typeof(VersionControlServer)); m_tfsClient.NonFatalError += new ExceptionEventHandler(NonFatalError); }
// 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)); }
public VSTSMonitor(TeamFoundationServer server, string stateFilePath, string projectPath, int port) { this.Server = server; this.StateFilePath = stateFilePath; this.ProjectPath = projectPath; this.Port = port; this.State = this.RetrieveState(); }
private WorkItemStore GetWorkItemStore(string serverUrl) { Trace.TraceInformation("Connecting to '{0}'", serverUrl); TeamFoundationServer tfs = new TeamFoundationServer(serverUrl); WorkItemStore wi = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); Trace.TraceInformation("Connected to '{0}'", serverUrl); return(wi); }
private void pickServerButton_Click(object sender, EventArgs e) { DomainProjectPicker dlg = new DomainProjectPicker(DomainProjectPickerMode.None); if (dlg.ShowDialog() == DialogResult.OK) { server = dlg.SelectedServer; Send(TeamServerNameChanged); } }
/// <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; }
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); }
public ChangesetInfo(string tfsServer, KnownFileTypes knownFileTypes) { if (string.IsNullOrWhiteSpace(tfsServer)) { throw new ArgumentNullException("tfsServer", "tfsServer is required"); } _tfs = Server.GetTfsServer(tfsServer); _versionControl = _tfs.GetService(typeof(VersionControlServer)) as VersionControlServer; _workItemStore = (WorkItemStore)_tfs.GetService(typeof(WorkItemStore)); this.Downloader = new WorkItemFileManager(knownFileTypes); }
/// <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); }