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


C# TfsTeamProjectCollection.GetService方法代码示例

本文整理汇总了C#中TfsTeamProjectCollection.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# TfsTeamProjectCollection.GetService方法的具体用法?C# TfsTeamProjectCollection.GetService怎么用?C# TfsTeamProjectCollection.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TfsTeamProjectCollection的用法示例。


在下文中一共展示了TfsTeamProjectCollection.GetService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MyTfsProjectCollection

 public MyTfsProjectCollection(CatalogNode teamProjectCollectionNode, TfsConfigurationServer tfsConfigurationServer, NetworkCredential networkCredential)
 {
     try
     {
         Name = teamProjectCollectionNode.Resource.DisplayName;
         ServiceDefinition tpcServiceDefinition = teamProjectCollectionNode.Resource.ServiceReferences["Location"];
         var configLocationService = tfsConfigurationServer.GetService<ILocationService>();
         var tpcUri = new Uri(configLocationService.LocationForCurrentConnection(tpcServiceDefinition));
         _tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcUri, new MyCredentials(networkCredential));
         _commonStructureService = _tfsTeamProjectCollection.GetService<ICommonStructureService>();
         _buildServer = _tfsTeamProjectCollection.GetService<IBuildServer>();
         _tswaClientHyperlinkService = _tfsTeamProjectCollection.GetService<TswaClientHyperlinkService>();
         CurrentUserHasAccess = true;
     }
     catch (TeamFoundationServiceUnavailableException ex)
     {
         _log.Debug("Can't access " + Name + ". This could be because the project collection is currently offline.", ex);
         CurrentUserHasAccess = false;
     }
     catch (TeamFoundationServerUnauthorizedException ex)
     {
         _log.Debug("Unauthorized access to " + teamProjectCollectionNode, ex);
         CurrentUserHasAccess = false;
     }
 }
开发者ID:jimbobTX,项目名称:SirenOfShame,代码行数:25,代码来源:MyTfsProjectCollection.cs

示例2: ProcessRecord

        protected override void ProcessRecord()
        {
            using (var collection = new TfsTeamProjectCollection(CollectionUri))
            {
                var cssService = collection.GetService<ICommonStructureService4>();
                var projectInfo = cssService.GetProjectFromName(TeamProject);

                var teamService = collection.GetService<TfsTeamService>();
                var tfsTeam = teamService.ReadTeam(projectInfo.Uri, Team, null);
                if (tfsTeam == null)
                {
                    WriteError(new ErrorRecord(new ArgumentException(string.Format("Team '{0}' not found.", Team)), "", ErrorCategory.InvalidArgument, null));
                    return;
                }

                var identityService = collection.GetService<IIdentityManagementService>();
                var identity = identityService.ReadIdentity(IdentitySearchFactor.AccountName, Member, MembershipQuery.Direct, ReadIdentityOptions.None);
                if (identity == null)
                {
                    WriteError(new ErrorRecord(new ArgumentException(string.Format("Identity '{0}' not found.", Member)), "", ErrorCategory.InvalidArgument, null));
                    return;
                }

                identityService.AddMemberToApplicationGroup(tfsTeam.Identity.Descriptor, identity.Descriptor);
                WriteVerbose(string.Format("Identity '{0}' added to team '{1}'", Member, Team));
            }
        }
开发者ID:jstangroome,项目名称:PsTfsTeams,代码行数:27,代码来源:AddUserCmdlet.cs

示例3: Main

        static void Main(string[] args)
        {
            // Try to parse options from command line
            var options = new Options();
            if (Parser.Default.ParseArguments(args, options))
            {
                try
                {
                    _collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(options.TeamCollection));
                    _buildServer = _collection.GetService<IBuildServer>();
                    _commonStructureService = _collection.GetService<ICommonStructureService>();
                    _printer = new TabbedPrinter();

                    PrintDefinitions(options);
                }
                catch (Exception ex)
                {
                    Console.WriteLine();
                    Console.WriteLine("An error occured:");
                    Console.WriteLine(ex.Message);
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("Couldn't read options");
                Console.WriteLine();
            }
        }
开发者ID:ferarias,项目名称:tfs-builddeftools,代码行数:29,代码来源:Program.cs

示例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);
            }
        }
开发者ID:miiitch,项目名称:wilinq,代码行数:26,代码来源:TestFixtureBase.cs

示例5: MainWindowViewModel

 public MainWindowViewModel()
 {
     server = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
         RegisteredTfsConnections.GetProjectCollections().First().Uri);
     workItemStore = (WorkItemStore)server.GetService(typeof(WorkItemStore));
     versionControl = server.GetService<VersionControlServer>();
     buildServer = (IBuildServer)server.GetService(typeof(IBuildServer));
     historyLoader = new HistoryLoader(versionControl);
     loadHistoryCommand = new DelegateCommand(LoadHistory);
 }
开发者ID:georgeslegros,项目名称:TFSConnector,代码行数:10,代码来源:MainWindowViewModel.cs

示例6: Load

        public override void Load()
        {
            var teamFoundationServerUrl = ConfigurationManager.AppSettings["TeamFoundationServerUrl"];
            var tfsUser = ConfigurationManager.AppSettings["TFS_User"];
            var tfsPassword = ConfigurationManager.AppSettings["TFS_Password"];
            var tfs = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName(teamFoundationServerUrl), new NetworkCredential(tfsUser, tfsPassword));

            Bind<IBuildServer>().ToMethod(ctx => tfs.GetService<IBuildServer>());
            Bind<VersionControlServer>().ToMethod(ctx => tfs.GetService<VersionControlServer>());
            Bind<ITestManagementService>().ToMethod(ctx => tfs.GetService<ITestManagementService>());

            Bind<IBuildService>().To<Tfs2010BuildService>().InSingletonScope();
        }
开发者ID:ovu,项目名称:TFSTimeLine,代码行数:13,代码来源:TfsServicesModule.cs

示例7: GetLatestBuildStates

        public IList<BuildState> GetLatestBuildStates()
        {
            using (TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(_configuration.TfsUrl), new NetworkCredential(_configuration.TfsUserName, _configuration.TfsPassword)))
            {
                IBuildServer buildServer = tfs.GetService<IBuildServer>();
                ITestManagementService testServer = tfs.GetService<ITestManagementService>();
                var defs = buildServer.QueryBuildDefinitions(_configuration.TfsTeamProjectName);
                return defs
                    .Select(def => GetLatestBuildDetails(buildServer, def))
                    .Where(build => build != null)
                    .Select(build => new BuildState(build.BuildDefinition.Name, build.Status, build.FinishTime, build.Uri.AbsoluteUri, build.RequestedFor,GetTestResults(testServer, build.Uri)))
                    .ToList();

            }
        }
开发者ID:madsny,项目名称:TfsToSlack,代码行数:15,代码来源:TfsClient.cs

示例8: Main

        private static void Main(string[] args)
        {
            var tfsUrl = "";
            var pbiNumber = 0;
            var optionSet = new OptionSet
            {
                {"pbi=", "The {PBI} Number", (int pbi) => pbiNumber = pbi},
                {"tfs=", "The {TFSURL} for the TFS Collection to use", url => { tfsUrl = url; }}
            };
            optionSet.Parse(args);

            var tpc = new TfsTeamProjectCollection(new Uri(tfsUrl));
            var workItemStore = tpc.GetService<WorkItemStore>();
            var vcServer = tpc.GetService<VersionControlServer>();

            var changesets = GetChangesets(workItemStore, vcServer, pbiNumber);

            Output("{0} changesets", changesets.Count);
            foreach (var changeset in changesets.OrderBy(n => n.Key).Select(n => n.Value))
            {
                Output("{0} - {1}", changeset.ChangesetId, changeset.Comment);
            }

            Output("");

            var files =
                changesets.Values.SelectMany(changeset => changeset.Changes,
                    (changeset, change) => new {change, changeset})
                    .Select(a => new
                    {
                        ChangeType = a.change.ChangeType.HasFlag(ChangeType.Add) ? ChangeType.Add : a.change.ChangeType,
                        FileName = a.change.Item.ServerItem.Substring(@"$/PwC-CMS/Development/Source/PwC CMS/".Length),
                        Changeset = a.changeset
                    })
                    .GroupBy(a => new {a.ChangeType, a.FileName}, a => a.Changeset)
                    .OrderBy(g => g.Key.ChangeType).ThenBy(g => g.Key.FileName)
                    .ToList();

            Output("{0} files", files.Count);
            foreach (var file in files)
            {
                Output("{0} - {1}", file.Key.ChangeType, file.Key.FileName);
                foreach (var changeset in file)
                {
                    Output("\t{0} - {1}", changeset.ChangesetId, changeset.Comment);
                }
            }
        }
开发者ID:JeffreyVest,项目名称:TfsPbiReader,代码行数:48,代码来源:Program.cs

示例9: Main

        public static void Main(string[] args)
        {
            try
            {
                var options = new Options();

                if (CommandLine.Parser.Default.ParseArgumentsStrict(args, options))
                {
                    TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri(options.TeamProjectCollectionUrl));

                    //Call Build
                    IBuildServer buildServer = collection.GetService<IBuildServer>();

                    IBuildDefinition definition = buildServer.GetBuildDefinition(options.TeamProjectName,
                                                                                 options.BuildDefinition);

                    IBuildRequest request = definition.CreateBuildRequest();
                    request.ProcessParameters = UpdateVersion(request.ProcessParameters, options);
                    request.DropLocation = options.DropLocation;
                    buildServer.QueueBuild(request);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in calling TFS Build: " + ex.Message);
            }
        }
开发者ID:renevanosnabrugge,项目名称:RoadToALM-TeamCity2TFS,代码行数:27,代码来源:Program.cs

示例10: Validation

        public Validation()
        {
            _tfsServer = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(ConfigurationManager.AppSettings["TfsServer"]));
            _vsoServer = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(ConfigurationManager.AppSettings["VsoServer"]));
            _vsoStore = _vsoServer.GetService<WorkItemStore>();
            _tfsStore = _tfsServer.GetService<WorkItemStore>();

            var actionValue = ConfigurationManager.AppSettings["Action"];
            if (actionValue.Equals("validate", StringComparison.OrdinalIgnoreCase))
            {
                _action = Action.Validate;
            }
            else
            {
                _action = Action.Compare;
            }

            var runDateTime = DateTime.Now.ToString("yyyy-MM-dd-HHmmss");

            var dataFilePath = ConfigurationManager.AppSettings["DataFilePath"];
            var dataDir = string.IsNullOrWhiteSpace(dataFilePath) ? Directory.GetCurrentDirectory() : dataFilePath;
            var dirName = string.Format("{0}\\Log-{1}",dataDir,runDateTime);

            if (!Directory.Exists(dirName))
            {
                Directory.CreateDirectory(dirName);
            }

            _errorLog = new Logging(string.Format("{0}\\Error.txt", dirName));
            _statusLog = new Logging(string.Format("{0}\\Status.txt", dirName));
            _fullLog = new Logging(string.Format("{0}\\FullLog.txt", dirName));

            _taskList = new List<Task>();

            if (!_action.Equals(Action.Compare))
            {
                return;
            }

            _valFieldErrorLog = new Logging(string.Format("{0}\\FieldError.txt", dirName));
            _valTagErrorLog = new Logging(string.Format("{0}\\TagError.txt", dirName));
            _valPostMigrationUpdateLog = new Logging(string.Format("{0}\\PostMigrationUpdate.txt", dirName));

            _imageLog = new Logging(string.Format("{0}\\ItemsWithImage.txt", dirName));

            _commonFields = new List<string>();
            _itemTypesToValidate = new List<string>();

            var fields = ConfigurationManager.AppSettings["CommonFields"].Split(',');
            foreach (var field in fields)
            {
                _commonFields.Add(field);
            }

            var types = ConfigurationManager.AppSettings["WorkItemTypes"].Split(',');
            foreach (var type in types)
            {
                _itemTypesToValidate.Add(type);
            }
        }
开发者ID:hshishir,项目名称:ValidationTool,代码行数:60,代码来源:Validation.cs

示例11: GetBuildStatus

        private static BuildStatus GetBuildStatus(TfsTeamProjectCollection collection)
        {
            var buildServer = collection.GetService<IBuildServer>();

            var builds = buildServer.QueryBuilds(teamProjectName);
            return builds.OrderByDescending(b => b.StartTime).First().Status;
        }
开发者ID:perkof,项目名称:BuildMonitor,代码行数:7,代码来源:Program.cs

示例12: 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;
        }
开发者ID:CSlatton,项目名称:hello-world,代码行数:37,代码来源:TFSActions.cs

示例13: SetConfiguration

        public void SetConfiguration(ConfigurationBase newConfiguration)
        {
            if (timer != null)
            {
                timer.Change(Timeout.Infinite, Timeout.Infinite);
            }

            configuration = newConfiguration as TeamFoundationConfiguration;
            if (configuration == null)
            {
                throw new ApplicationException("Configuration can not be null.");
            }

            var credentialProvider = new PlainCredentialsProvider(configuration.Username, configuration.Password);

            var teamProjectCollection = new TfsTeamProjectCollection(new Uri(configuration.CollectionUri), credentialProvider);
            buildServer = teamProjectCollection.GetService<IBuildServer>();

            if (timer == null)
            {
                timer = new Timer(Tick, null, 0, configuration.PollInterval);
            }
            else
            {
                timer.Change(0, configuration.PollInterval);
            }
        }
开发者ID:chuck-n0rris,项目名称:AchtungPolizei,代码行数:27,代码来源:TeamFoundationPlugin.cs

示例14: GetNewWorkItem

        public WorkItem GetNewWorkItem(TfsTeamProjectCollection conn, string projectName, string WIType, string areaPath, string iterationPath, string title, string description)
        {
            try
            {
                WorkItemStore workItemStore = conn.GetService<WorkItemStore>();
                Project prj = workItemStore.Projects[projectName];
                WorkItemType workItemType = prj.WorkItemTypes[WIType];


                var WIToAdd = new WorkItem(workItemType)
                {
                    Title = title,
                    Description = description,
                    IterationPath = iterationPath,
                    AreaPath = areaPath,
                };

                return WIToAdd;
            }
            catch (Exception ex)
            {
                Logger.Fatal(new LogInfo(MethodBase.GetCurrentMethod(), "ERR", string.Format("Si è verificato un errore durante la creazione del work Item. Dettagli: {0}", ex.Message)));
                throw ex;
            }
        }
开发者ID:AlmatoolboxCE,项目名称:MailToWI,代码行数:25,代码来源:WIAdder.cs

示例15: 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


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