本文整理汇总了C#中TfsTeamProjectCollection.EnsureAuthenticated方法的典型用法代码示例。如果您正苦于以下问题:C# TfsTeamProjectCollection.EnsureAuthenticated方法的具体用法?C# TfsTeamProjectCollection.EnsureAuthenticated怎么用?C# TfsTeamProjectCollection.EnsureAuthenticated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TfsTeamProjectCollection
的用法示例。
在下文中一共展示了TfsTeamProjectCollection.EnsureAuthenticated方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetService
public object GetService(Type serviceType)
{
var collection = new TfsTeamProjectCollection(_projectCollectionUri);
object service;
try
{
if (_buildConfigurationManager.UseCredentialToAuthenticate)
{
collection.Credentials = new NetworkCredential(_buildConfigurationManager.TfsAccountUserName,
_buildConfigurationManager.TfsAccountPassword, _buildConfigurationManager.TfsAccountDomain);
}
collection.EnsureAuthenticated();
service = collection.GetService(serviceType);
}
catch (Exception ex)
{
Tracing.Client.TraceError(
String.Format("Error communication with TFS server: {0} detail error message {1} ",
_projectCollectionUri, ex));
throw;
}
Tracing.Client.TraceInformation("Connection to TFS established.");
return service;
}
示例2: 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");
}
示例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: CollectionExists
public static bool CollectionExists(Uri collectionUri, ICredentials credentials, out bool isAuthorized)
{
TfsTeamProjectCollection collection = null;
try
{
collection = new TfsTeamProjectCollection(collectionUri, credentials);
collection.EnsureAuthenticated();
isAuthorized = true;
return true;
}
catch (TeamFoundationServerUnauthorizedException)
{
isAuthorized = false;
return true;
}
catch
{
isAuthorized = false;
return false;
}
finally
{
collection.Dispose();
collection = null;
}
}
示例5: RepositoryBase
protected RepositoryBase(String username, String password, string domain, string projectCollection, String url)
{
string fullUrl = url;
bool collectionExists = !String.IsNullOrEmpty(projectCollection);
if (String.IsNullOrEmpty(username))
throw new ArgumentNullException(username, "Username is null or empty!");
if (String.IsNullOrEmpty(password))
throw new ArgumentNullException(password, "Password is null or empty!");
if (collectionExists)
fullUrl = url.LastIndexOf('/') == url.Length - 1
? String.Concat(url, projectCollection)
: String.Concat(url, "/", projectCollection);
if (String.IsNullOrEmpty(url))
throw new ArgumentNullException(url, "TFSServerUrl is null or empty!");
var credentials = new NetworkCredential(username, password, domain);
_configuration = new TfsConfigurationServer(new Uri(url), credentials);
_configuration.EnsureAuthenticated();
if (collectionExists)
{
_tfs = new TfsTeamProjectCollection(new Uri(fullUrl), credentials);
_tfs.EnsureAuthenticated();
}
}
示例6: Conectar
public void Conectar(Uri uri, NetworkCredential credential)
{
TeamProjectCollection = credential == null ?
new TfsTeamProjectCollection(uri) :
new TfsTeamProjectCollection(uri, credential);
TeamProjectCollection.EnsureAuthenticated();
}
示例7: TfsRepository
public TfsRepository(TfsTeamProjectCollection tfs, ITfsProjectProvider projectProvider, string projectName)
{
_tfs = tfs;
_tfs.EnsureAuthenticated();
_projectProvider = projectProvider;
_projectProvider.Initialize(_tfs, projectName);
}
示例8: TFSAPI
/// <summary>
/// Create a new instance of TFSAPI Class
/// </summary>
/// <param name="TfsCollectionURI">URI to access the TFS Server and project collection</param>
/// <param name="ProjectName">Default project</param>
public TFSAPI(Uri TfsCollectionURI, string ProjectName)
{
teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(TfsCollectionURI);
teamProjectCollection.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.IncludeServices);
teamProjectCollection.EnsureAuthenticated();
wiStore = new WorkItemStore(teamProjectCollection);
workItemTypeCollection = wiStore.Projects[ProjectName].WorkItemTypes;
}
示例9: GetWorkItemStore
private static WorkItemStore GetWorkItemStore(ISourceControlConnectionSettingsSource settings)
{
TfsConnectionParameters parameters = TfsConnectionHelper.GetTfsConnectionParameters(settings);
var teamProjectCollection = new TfsTeamProjectCollection(parameters.TfsCollectionUri, parameters.Credential);
teamProjectCollection.EnsureAuthenticated();
var workItemStore = teamProjectCollection.GetService<WorkItemStore>();
return workItemStore;
}
示例10: UpdateServer
private void UpdateServer()
{
if (string.IsNullOrEmpty(Url))
{
server = null;
}
else
{
server = new TfsTeamProjectCollection(new Uri(Url), new UICredentialsProvider());
server.EnsureAuthenticated();
}
}
示例11: ChangeConnection
private void ChangeConnection()
{
if (!string.IsNullOrEmpty(this.ctx.ActiveConnection))
{
var collection = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName(this.ctx.ActiveConnection), new TfsClientCredentials());
collection.EnsureAuthenticated();
var view = this.Content as MainView;
view.InitializeContext(this.ctx);
view.InitializeRepository(new TfsClientRepository(collection));
}
}
示例12: Authenticate
private void Authenticate(string tfsUrl)
{
try
{
var credentials = new UICredentialsProvider();
m_tpc = new TfsTeamProjectCollection(new Uri(tfsUrl), credentials);
m_tpc.EnsureAuthenticated();
}
catch
{
m_tpc = null;
throw;
}
}
示例13: TFS2010
public TFS2010(string servername, string domain, string username, string password)
{
if (string.IsNullOrEmpty(servername))
throw new ArgumentException("Parameter named:servername cannot be null or empty.");
if (string.IsNullOrEmpty(username))
throw new ArgumentException("Parameter named:username cannot be null or empty.");
if (string.IsNullOrEmpty(password))
throw new ArgumentException("Parameter named:password cannot be null or empty.");
//ICredentialsProvider provider = new UICredentialsProvider();
//tfsConfigurationServer = TeamFoundationServerFactory.GetServer(serverName, provider);
//if (!tfsConfigurationServer.HasAuthenticated)
// tfsConfigurationServer.Authenticate();
//tfsConfigurationServer = new TfsConfigurationServer(new Uri(string.Concat("http://", servername)),
// new NetworkCredential(username, password, domain));
//TeamProjectPicker pp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false);
//pp.ShowDialog();
//var coll = new TfsTeamProjectCollection(new Uri(string.Concat("http://", servername)), new UICredentialsProvider());
var tfsTeamProjectCollection = new TfsTeamProjectCollection(new Uri(string.Concat("http://", servername)), new NetworkCredential(username, password, domain));
tfsTeamProjectCollection.EnsureAuthenticated();
store = (WorkItemStore)tfsTeamProjectCollection.GetService(typeof(WorkItemStore));
//var processTemplates = (IProcessTemplates)tfsTeamProjectCollection.GetService(typeof(IProcessTemplates));
//var node = processTemplates.GetTemplateNames();
//ICommonStructureService css = (ICommonStructureService)tfsTeamProjectCollection.GetService(typeof(ICommonStructureService));
//ProjectInfo projectInfo = css.GetProjectFromName(store.Projects[5].Name);
//String projectName;
//String prjState;
//int templateId = 0;
//ProjectProperty[] projectProperties;
//css.GetProjectProperties(
// projectInfo.Uri, out projectName, out prjState, out templateId, out projectProperties);
// //tfsConfigurationServer.Authenticate();
// var tpcService = tfsConfigurationServer.GetService<ITeamProjectCollectionService>();
//var collections = tpcService.GetCollections();
// //var wstore= ((TfsTeamProjectCollection )collections[0]).GetService(typeof (WorkItemStore));
// var ws=tpcService.GetServicingOperation("WorkItemStore");
// store = (WorkItemStore) tfsConfigurationServer.GetService(typeof (WorkItemStore));
}
示例14: GetTeamProjectCollection
internal static TfsTeamProjectCollection GetTeamProjectCollection(TfsConfigurer configurer)
{
if (configurer.UseSystemCredentials)
{
var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(configurer.BaseUri);
projectCollection.EnsureAuthenticated();
return projectCollection;
}
else
{
var projectCollection = new TfsTeamProjectCollection(configurer.BaseUri, new TfsClientCredentials(new WindowsCredential(new NetworkCredential(configurer.UserName, configurer.Password, configurer.Domain))));
projectCollection.EnsureAuthenticated();
return projectCollection;
}
}
示例15: TFS2010
public TFS2010(string servername, string domain, string username, string password)
{
if (string.IsNullOrEmpty(servername))
throw new ArgumentException("Parameter named:servername cannot be null or empty.");
if (string.IsNullOrEmpty(username))
throw new ArgumentException("Parameter named:username cannot be null or empty.");
if (string.IsNullOrEmpty(password))
throw new ArgumentException("Parameter named:password cannot be null or empty.");
tfsTeamProjectCollection = new TfsTeamProjectCollection(new Uri(string.Concat("http://", servername)),
new NetworkCredential(username, password, domain));
tfsTeamProjectCollection.EnsureAuthenticated();
store = (WorkItemStore) tfsTeamProjectCollection.GetService(typeof (WorkItemStore));
}