本文整理汇总了C#中TfsTeamProjectCollection.Authenticate方法的典型用法代码示例。如果您正苦于以下问题:C# TfsTeamProjectCollection.Authenticate方法的具体用法?C# TfsTeamProjectCollection.Authenticate怎么用?C# TfsTeamProjectCollection.Authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TfsTeamProjectCollection
的用法示例。
在下文中一共展示了TfsTeamProjectCollection.Authenticate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: PopulateProjectNameComboBox
private void PopulateProjectNameComboBox()
{
string url = tfsAddressTextBox.Text;
string username = tfsUsernameTextBox.Text;
string password = tfsPasswordTextBox.Text;
Uri tfsUri;
if (!Uri.TryCreate(url, UriKind.Absolute, out tfsUri))
return;
var credentials = new System.Net.NetworkCredential();
if (!string.IsNullOrEmpty(username))
{
credentials.UserName = username;
credentials.Password = password;
}
var tfs = new TfsTeamProjectCollection(tfsUri, credentials);
tfs.Authenticate();
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;
}
示例3: ConfigureAsync
/// <inheritdoc/>
public async Task ConfigureAsync(TfsServiceProviderConfiguration configuration)
{
if (configuration == null)
{
throw new ArgumentNullException(nameof(configuration));
}
if(string.IsNullOrEmpty(configuration.WorkItemType))
{
throw new ArgumentNullException(nameof(configuration.WorkItemType));
}
this.logger.Debug("Configure of TfsSoapServiceProvider started...");
var networkCredential = new NetworkCredential(configuration.Username, configuration.Password);
var tfsClientCredentials = new TfsClientCredentials(new BasicAuthCredential(networkCredential)) { AllowInteractive = false };
var tfsProjectCollection = new TfsTeamProjectCollection(this.serviceUri, tfsClientCredentials);
this.workItemType = configuration.WorkItemType;
tfsProjectCollection.Authenticate();
tfsProjectCollection.EnsureAuthenticated();
this.logger.Debug("Authentication successful for {serviceUri}.", this.serviceUri.AbsoluteUri);
await Task.Run(
() =>
{
this.logger.Debug("Fetching workitem for id {parentWorkItemId}.", configuration.ParentWorkItemId);
this.workItemStore = new WorkItemStore(tfsProjectCollection);
this.parentWorkItem = this.workItemStore.GetWorkItem(configuration.ParentWorkItemId);
this.logger.Debug("Found parent work item '{title}'.", this.parentWorkItem.Title);
});
this.logger.Verbose("Tfs service provider configuration complete.");
}
示例4: SetUp
public virtual void SetUp()
{
var collectionUrl = Environment.GetEnvironmentVariable("WILINQ_TEST_TPCURL");
if (string.IsNullOrWhiteSpace(collectionUrl))
{
collectionUrl = "http://localhost:8080/tfs/DefaultCollection";
}
TPC = new TfsTeamProjectCollection(new Uri(collectionUrl));
TPC.Authenticate();
var projectName = Environment.GetEnvironmentVariable("WILINQ_TEST_PROJECTNAME");
// ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
if (string.IsNullOrWhiteSpace(projectName))
{
Project = TPC.GetService<WorkItemStore>().Projects.Cast<Project>().First();
}
else
{
Project = TPC.GetService<WorkItemStore>().Projects.Cast<Project>().First(_ => _.Name == projectName);
}
}
示例5: GenerateTfsConnection
public TfsTeamProjectCollection GenerateTfsConnection()
{
var tfs= new TfsTeamProjectCollection(GetTfsUri(), GetNetworkCredential());
tfs.Authenticate();
tfs.Connect(new ConnectOptions());
return tfs;
}
示例6: Authorize
public TfsTeamProjectCollection Authorize(IDictionary<string, string> authorizeInformation)
{
var tfsCredentials = new TfsClientCredentials();
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(this.tfsUri));
tfs.Authenticate();
return tfs;
}
示例7: Connection
public TfsTeamProjectCollection Connection()
{
string tfsUrl = _settings.TfsUrl;
ICredentials credentials = (_settings.TfsUseDomainCredentials)
? System.Net.CredentialCache.DefaultCredentials
: new NetworkCredential(_settings.TfsUsername, _settings.TfsPassword, _settings.TfsDomain);
var server = new TfsTeamProjectCollection(new System.Uri(tfsUrl), credentials);
server.Authenticate();
return server;
}
示例8: Initialize
public void Initialize(BuildConfig config)
{
NetworkCredential credentials = new NetworkCredential(config.Username, config.Password);
BasicAuthCredential basicCredentials = new BasicAuthCredential(credentials);
TfsClientCredentials cred = new TfsClientCredentials(basicCredentials);
cred.AllowInteractive = false;
tpc = new TfsTeamProjectCollection(new Uri(config.SourceUrl + "/" + config.Collection),cred);
tpc.Authenticate();
this.Server = tpc.GetService<Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer>();
}
示例9: Main
static void Main(string[] args)
{
var options = new Options();
if (!CommandLine.Parser.Default.ParseArguments(args, options))
{
Console.WriteLine(options.GetUsage());
return;
}
// Connect to the desired Team Foundation Server
TfsTeamProjectCollection tfsServer = new TfsTeamProjectCollection(new Uri(options.ServerNameUrl));
// Authenticate with the Team Foundation Server
tfsServer.Authenticate();
// Get a reference to a Work Item Store
var workItemStore = new WorkItemStore(tfsServer);
var project = GetProjectByName(workItemStore, options.ProjectName);
if (project == null)
{
Console.WriteLine($"Could not find project '{options.ProjectName}'");
return;
}
var query = GetWorkItemQueryByName(workItemStore, project, options.QueryPath);
if (query == null)
{
Console.WriteLine($"Could not find query '{options.QueryPath}' in project '{options.ProjectName}'");
return;
}
var queryText = query.QueryText.Replace("@project", $"'{project.Name}'");
Console.WriteLine($"Executing query '{options.QueryPath}' with text '{queryText}'");
var count = workItemStore.QueryCount(queryText);
Console.WriteLine($"Exporting {count} work items");
var workItems = workItemStore.Query(queryText);
foreach (WorkItem workItem in workItems)
{
StoreAttachments(workItem, options.OutputPath);
}
}
示例10: Authorize
public TfsTeamProjectCollection Authorize(IDictionary<string, string> authorizeInformation)
{
////TeamProjectPicker picker = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, true);
////picker.ShowDialog();
////ProjectInfo[] projects = picker.SelectedProjects[0].;
NetworkCredential cred = new NetworkCredential(authorizeInformation["username"], authorizeInformation["password"]);
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(this.tfsUri), cred);
tfs.Authenticate();
return tfs;
}
示例11: TfsProjects
/// <summary>
/// Prevents a default instance of the <see cref="TfsProjects"/> class from being created.
/// This might change if the project name can be optional.
/// </summary>
public TfsProjects(string tfsUri, string username, string password, string projectName = null)
{
NetworkCredential netCred = new NetworkCredential(username, password);
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
ProjectCollection = new TfsTeamProjectCollection(new Uri(tfsUri), tfsCred);
ProjectCollection.Authenticate();
Store = new WorkItemStore(ProjectCollection);
ProjectName = projectName;
}
示例12: Authorize
public TfsTeamProjectCollection Authorize(IDictionary<string, string> authorizeInformation)
{
NetworkCredential netCred = new NetworkCredential(
"[email protected]",
"yourbasicauthpassword");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
new Uri("https://YourAccountName.visualstudio.com/DefaultCollection"),
tfsCred);
tpc.Authenticate();
return tpc;
}
示例13: Process
public void Process(string[] projectPaths, DateTime from, Stream outStream)
{
var credential = new System.Net.NetworkCredential(_username, _password, _domain);
var server = new TfsTeamProjectCollection(new Uri(_tfsUrl), credential);
server.Authenticate();
var history = new List<Changeset>();
foreach (var projectPath in projectPaths)
{
var projectPathTemp = projectPath.Trim();
var source = server.GetService<VersionControlServer>();
Console.WriteLine("Searching history for project {0}", projectPathTemp);
var projectHistory = source.QueryHistory(projectPathTemp, VersionSpec.Latest, 0, RecursionType.Full,
null, new DateVersionSpec(from), null, int.MaxValue,
true,
false, false, false).OfType<Changeset>().Reverse().ToList();
projectHistory = projectHistory.Where(item => item.CreationDate > from).ToList();
history.AddRange(projectHistory);
}
var orderedHistory = history.OrderBy(m => m.CreationDate);
using (var writer = new StreamWriter(outStream))
{
foreach (var item in orderedHistory) // history.ForEach(item =>
{
Console.WriteLine("Found changeset id = {0}. Committed: {1}", item.ChangesetId, item.CreationDate);
String committer = item.Committer;
if (_usernameSubstitution.ContainsKey(committer.ToLower()))
committer = _usernameSubstitution[committer.ToLower()];
foreach (Change change in item.Changes)
{
ChangeType changeType = change.ChangeType;
if (!AllowedTypes.Any(type => (type.Key & changeType) != 0))
continue;
KeyValuePair<ChangeType, string> code = AllowedTypes.FirstOrDefault(type => (type.Key & changeType) != 0);
writer.WriteLine(LogFormat, DateTimeToUnix(item.CreationDate), committer, code.Value,
change.Item.ServerItem);
}
}
}
Console.WriteLine("Processing finished");
}
示例14: ConnectToTFS
public static TfsTeamProjectCollection ConnectToTFS()
{
var config = new ConfigurationProxy().Retrieve();
var user = config.TfsUserName;
var domain = string.Empty;
var pos = config.TfsUserName.IndexOf('\\');
if (pos >= 0)
{
domain = config.TfsUserName.Substring(0, pos);
user = user.Substring(pos + 1);
}
var creds = new NetworkCredential(user, config.TfsPassword, domain);
var tfsServer = new TfsTeamProjectCollection(new Uri(config.TfsUrl), creds);
tfsServer.Authenticate();
return tfsServer;
}
示例15: Authenticate
public static NetworkCredential Authenticate()
{
if (credentials == null)
{
Start:
NetworkCredential credential;
if (!TryReadCredentials(out credential))
{
var login = AskLogin();
var password = AskPassword();
credential = new NetworkCredential(login, password);
}
try
{
Console.WriteLine("-----Authentication------");
Console.WriteLine("Started...");
var projectCollection = new TfsTeamProjectCollection(Config.TfsCollectionUrl, credential);
projectCollection.Authenticate();
credentials = credential;
WriteCredentials(credential.UserName, credential.Password);
Console.WriteLine("Successfully completed.");
Console.WriteLine("-------------------------");
Console.WriteLine("");
}
catch (Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException ex)
{
ClearCredentials();
Console.Clear();
Console.WriteLine("Couldn't connect to TFS. Try again");
Console.WriteLine(ex.Message);
Console.WriteLine("");
goto Start;
}
}
return credentials;
}