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


C# TfsTeamProjectCollection.EnsureAuthenticated方法代码示例

本文整理汇总了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;
        }
开发者ID:Hdesai,项目名称:XBuildLight,代码行数:28,代码来源:TfsServiceProvider.cs

示例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");
        }
开发者ID:modulexcite,项目名称:mail2bug,代码行数:25,代码来源:TFSWorkItemManager.cs

示例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.");
        }
开发者ID:acesiddhu,项目名称:supa,代码行数:32,代码来源:TfsSoapServiceProvider.cs

示例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;
            }
        }
开发者ID:wullemsb,项目名称:TFS-Monitor,代码行数:30,代码来源:TFSBaseProxy.cs

示例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();
            }
        }
开发者ID:ExtraordinaryJerks,项目名称:relax-for-tfs,代码行数:27,代码来源:RepositoryBase.cs

示例6: Conectar

        public void Conectar(Uri uri, NetworkCredential credential)
        {
            TeamProjectCollection = credential == null ?
                new TfsTeamProjectCollection(uri) :
                new TfsTeamProjectCollection(uri, credential);

            TeamProjectCollection.EnsureAuthenticated();
        }
开发者ID:yanjustino,项目名称:otfs,代码行数:8,代码来源:TeamFoundationDataContext.cs

示例7: TfsRepository

        public TfsRepository(TfsTeamProjectCollection tfs, ITfsProjectProvider projectProvider, string projectName)
        {
            _tfs = tfs;
            _tfs.EnsureAuthenticated();

            _projectProvider = projectProvider;
            _projectProvider.Initialize(_tfs, projectName);
        }
开发者ID:DmitriySokhach,项目名称:KanbanizeTFSToolkit,代码行数:8,代码来源:TfsRepository.cs

示例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;
        }
开发者ID:rolandocc,项目名称:TFSAPIWrapper,代码行数:15,代码来源:TFSAPI.cs

示例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;
		}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:11,代码来源:TfsWorkItemStoreClient.cs

示例10: UpdateServer

 private void UpdateServer()
 {
     if (string.IsNullOrEmpty(Url))
     {
         server = null;
     }
     else
     {
         server = new TfsTeamProjectCollection(new Uri(Url), new UICredentialsProvider());
         server.EnsureAuthenticated();
     }
 }
开发者ID:jsmale,项目名称:git-tfs,代码行数:12,代码来源:TfsHelper.Vs2010.cs

示例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));
            }
        }
开发者ID:NikolayKash,项目名称:BuildManager,代码行数:12,代码来源:BuildManagerToolWindow.cs

示例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;
     }
 }
开发者ID:starkmsu,项目名称:TfsRetrospectiveTool,代码行数:14,代码来源:TfsAccessor.cs

示例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));
        }
开发者ID:ricred,项目名称:PivotalTFS,代码行数:49,代码来源:TFS2010.cs

示例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;
     }
 }
开发者ID:mwpnl,项目名称:bmx-tfs2012,代码行数:15,代码来源:TfsActionBase.cs

示例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));
        }
开发者ID:ricred,项目名称:PivotalTFS,代码行数:16,代码来源:TFS2010.cs


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