public BuildDefinitionsServiceModel(ITeamPilgrimServiceModelProvider teamPilgrimServiceModelProvider, ITeamPilgrimVsService teamPilgrimVsService, TfsTeamProjectCollection collection, Project project)
            : base(teamPilgrimServiceModelProvider, teamPilgrimVsService)
        {
            BuildDefinitions = new ObservableCollection<BuildDefinitionModel>();

            _collection = collection;
            _project = project;

            OpenBuildDefintionCommand = new RelayCommand<BuildDefinitionModel>(OpenBuildDefinition, CanOpenBuildDefinition);
            ViewBuildsCommand = new RelayCommand<BuildDefinitionModel>(ViewBuilds, CanViewBuilds);
            DeleteBuildDefinitionCommand = new RelayCommand<BuildDefinitionModel>(DeleteBuildDefinition, CanDeleteBuildDefinition);
            CloneBuildDefinitionCommand = new RelayCommand<BuildDefinitionModel>(CloneBuildDefinition, CanCloneBuildDefinition);
            QueueBuildCommand = new RelayCommand<BuildDefinitionModel>(QueueBuild, CanQueueBuild);
            OpenProcessFileLocationCommand = new RelayCommand<BuildDefinitionModel>(OpenProcessFileLocation, CanOpenProcessFileLocation);
            ManageBuildDefinitionSecurityCommand = new RelayCommand<BuildDefinitionModel>(ManageBuildDefinitionSecurity, CanManageBuildDefinitionSecurity);

            NewBuildDefinitionCommand = new RelayCommand(NewBuildDefinition, CanNewBuildDefinition);
            ManageBuildControllersCommand = new RelayCommand(ManageBuildControllers, CanManageBuildControllers);
            ManageBuildQualitiesCommand = new RelayCommand(ManageBuildQualities, CanManageBuildQualities);
            ManageBuildSecurityCommand = new RelayCommand(ManageBuildSecurity, CanManageBuildSecurity);

            _populateBackgroundWorker = new BackgroundWorker();
            _populateBackgroundWorker.DoWork += PopulateBackgroundWorkerOnDoWork;
            _populateBackgroundWorker.RunWorkerAsync();
        }
        public ProjectServiceModel(ITeamPilgrimServiceModelProvider teamPilgrimServiceModelProvider, ITeamPilgrimVsService teamPilgrimVsService, TeamPilgrimServiceModel teamPilgrimServiceModel, TfsTeamProjectCollection tfsTeamProjectCollection, Project project)
            : base(teamPilgrimServiceModelProvider, teamPilgrimVsService)
        {
            TeamPilgrimServiceModel = teamPilgrimServiceModel;
            TfsTeamProjectCollection = tfsTeamProjectCollection;
            Project = project;

            ShowProjectAlertsCommand = new RelayCommand(ShowProjectAlerts, CanShowProjectAlerts);
            OpenSourceControlCommand = new RelayCommand(OpenSourceControl, CanOpenSourceControl);
            OpenPortalSettingsCommand = new RelayCommand(OpenPortalSettings, CanOpenPortalSettings);
            OpenSourceControlSettingsCommand = new RelayCommand(OpenSourceControlSettings, CanOpenSourceControlSettings);
            OpenAreasAndIterationsCommand = new RelayCommand(OpenAreasAndIterations, CanOpenAreasAndIterations);
            ShowSecuritySettingsCommand = new RelayCommand(ShowSecuritySettings, CanShowSecuritySettings);
            OpenGroupMembershipCommand = new RelayCommand(OpenGroupMembership, CanOpenGroupMembership);

            BuildDefinitionsServiceModel = new BuildDefinitionsServiceModel(teamPilgrimServiceModelProvider, teamPilgrimVsService, tfsTeamProjectCollection, project);

            WorkItemQueryServiceModel = new WorkItemQueryServiceModel(teamPilgrimServiceModelProvider, teamPilgrimVsService, tfsTeamProjectCollection, project);

            ChildObjects = new ObservableCollection<BaseModel>
                {
                    WorkItemQueryServiceModel,
                    BuildDefinitionsServiceModel,
                    new SourceControlModel()
                };

            IsActive = teamPilgrimVsService.ActiveProjectContext.ProjectName == Project.Name;
        }
예제 #3
0
        /// <summary>
        ///     Ищем среди всех итераций проекта подходящие по дате
        /// </summary>
        /// <param name="project"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        protected List <Iteration> FindIterations(Project project, DateTime start, DateTime end)
        {
            try
            {
                var iters = project
                            .IterationRootNodes
                            .OfType <Node>()
                            .Select(x => StructureService.GetNode(x.Uri.AbsoluteUri))
                            .AsParallel()
                            .ToList();

                return(iters
                       .Where(x => x.InRange(start, end))
                       .Select(x => new Iteration(x))
                       .ToList());
            }
            catch (SecurityException)
            {
                Trace.WriteLine($"{nameof(CapacitySearcher)}.{nameof(FindIterations)}: Not enough privileges");
                return(null);
            }
            catch (Exception e)
            {
                Trace.WriteLine($"{nameof(CapacitySearcher)}.{nameof(FindIterations)}: " + e);
                return(null);
            }
        }
        public WorkItemQueryServiceModel(ITeamPilgrimServiceModelProvider teamPilgrimServiceModelProvider, ITeamPilgrimVsService teamPilgrimVsService, TfsTeamProjectCollection projectCollection, Project project)
            : base(teamPilgrimServiceModelProvider, teamPilgrimVsService)
        {
            _projectCollection = projectCollection;
            _project = project;

            QueryItems = new ObservableCollection<WorkItemQueryChildModel>();

            NewWorkItemCommand = new RelayCommand<string>(NewWorkItem, CanNewWorkItem);

            GoToWorkItemCommand = new RelayCommand(GoToWorkItem, CanGoToWorkItem);

            NewQueryDefinitionCommand = new RelayCommand<WorkItemQueryFolderModel>(NewQueryDefinition, CanNewQueryDefinition);
            NewQueryFolderCommand = new RelayCommand<WorkItemQueryFolderModel>(NewQueryFolder, CanNewQueryFolder);

            OpenQueryDefinitionCommand = new RelayCommand<WorkItemQueryDefinitionModel>(OpenQueryDefinition, CanOpenQueryDefinition);
            EditQueryDefinitionCommand = new RelayCommand<WorkItemQueryDefinitionModel>(EditQueryDefinition, CanEditQueryDefinition);

            DeleteQueryItemCommand = new RelayCommand<WorkItemQueryChildModel>(DeleteQueryDefinition, CanDeleteQueryDefinition);
            OpenSeurityDialogCommand = new RelayCommand<WorkItemQueryChildModel>(OpenSeurityDialog, CanOpenSeurityDialog);

            _populateBackgroundWorker = new BackgroundWorker();
            _populateBackgroundWorker.DoWork +=PopulateBackgroundWorkerOnDoWork;
            _populateBackgroundWorker.RunWorkerAsync();
        }
        public static WorkItemQueryChildModel[] GetQueryItemViewModels(this IEnumerable<QueryItem> queryHierarchy, IWorkItemQueryCommandModel workItemQueryCommandModel, ITeamPilgrimServiceModelProvider teamPilgrimServiceModelProvider, ITeamPilgrimVsService teamPilgrimVsService, Project project, int depth)
        {
            return queryHierarchy.Select<QueryItem, WorkItemQueryChildModel>(item =>
                {
                    var queryFolder = item as QueryFolder;
                    if (queryFolder != null)
                    {
                        QueryFolderTypeEnum? queryFolderType = null;
                        if (depth == 1)
                        {
                            switch (queryFolder.Name)
                            {
                                case "My Queries":
                                    queryFolderType = QueryFolderTypeEnum.MyQueries;
                                    break;

                                case "Team Queries":
                                    queryFolderType = QueryFolderTypeEnum.TeamQueries;
                                    break;
                            }
                        }

                        var foldersChildren = queryFolder.GetQueryItemViewModels(workItemQueryCommandModel, teamPilgrimServiceModelProvider, teamPilgrimVsService, project, depth + 1);
                        return new WorkItemQueryFolderModel(workItemQueryCommandModel, project, depth, queryFolder, foldersChildren, queryFolderType);
                    }

                    var queryDefinition = item as QueryDefinition;
                    if (queryDefinition != null)
                    {
                        return new WorkItemQueryDefinitionModel(workItemQueryCommandModel, project, depth, queryDefinition);
                    }

                    throw new ArgumentException(item.GetType().ToString());
                }).ToArray();
        }
예제 #6
0
        public TFSWorkItemManager(Config.InstanceConfig config)
        {
            ValidateConfig(config);

            _config = config;

            // Init TFS service objects
            _tfsServer = ConnectToTfsCollection();
            Logger.InfoFormat("Connected to TFS. Getting TFS WorkItemStore");

            _tfsStore = _tfsServer.GetService<WorkItemStore>();

            if (_tfsStore == null)
            {
                Logger.ErrorFormat("Cannot initialize TFS Store");
                throw new Exception("Cannot initialize TFS Store");
            }

            Logger.InfoFormat("Geting TFS Project");
            _tfsProject = _tfsStore.Projects[config.TfsServerConfig.Project];

            Logger.InfoFormat("Initializing WorkItems Cache");
            InitWorkItemsCache();

            _nameResolver = InitNameResolver();
        }
예제 #7
0
        public bool TryConnectToTfs()
        {
            if (_isConnected)
            {
                return(true);
            }

            var accountUri = new Uri(_adoApiSettings.AdoUrl);

            _tfsCollection = new TfsTeamProjectCollection(
                accountUri,
                new VssBasicCredential("", _adoApiSettings.AdoToken.Value));

            Logger.Debug("Try connect to TFS {url}", accountUri);

            _tfsCollection.Authenticate();

            //we need to bypass rules if we want to load data in the past.
            _workItemStore = new WorkItemStore(_tfsCollection, WorkItemStoreFlags.BypassRules);
            TfsProject     = _workItemStore.Projects[_adoApiSettings.AdoProject];

            Logger.Debug("Loaded project {projectName} {url}", TfsProject.Name, TfsProject.Uri);

            return(_isConnected = true);
        }
 public WorkItemRead(TfsTeamProjectCollection tfs, Project sourceProject)
 {
     this.tfs = tfs;
     projectName = sourceProject.Name;
     store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
     queryCol = store.Projects[sourceProject.Name].QueryHierarchy;
     workItemTypes = store.Projects[sourceProject.Name].WorkItemTypes;
 }
 public void Initialize(TfsTeamProjectCollection tfs, string projectName)
 {
     _isInitialized = true;
     _workItemStore = tfs.GetService<WorkItemStore>();
     _project = _workItemStore.Projects
             .Cast<Project>()
             .SingleOrDefault(p => p.Name.Equals(projectName));
 }
예제 #10
0
 public QueryManager(Project project, TreeView tree, WorkItemStore itemStore)
 {
     ItemStore = itemStore;
     this.project = project;
     Tree = tree;
     project.QueryHierarchy.Refresh();
     BuildQueryHierarchy(project.QueryHierarchy);
 }
예제 #11
0
 public WorkItemWrite(TfsTeamProjectCollection tfs, Project destinationProject)
 {
     this.tfs = tfs;
     projectName = destinationProject.Name;
     this.destinationProject = destinationProject;
     store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
     queryCol = store.Projects[destinationProject.Name].QueryHierarchy;
     workItemTypes = store.Projects[destinationProject.Name].WorkItemTypes;
     itemMap = new Hashtable();
     itemMapCIC = new Hashtable();
 }
예제 #12
0
        public LinqCodeGenerationViewModel(Project project)
        {
            if (project == null)
                throw new ArgumentNullException("project", @"project is null.");

            CSharpCode = true;
            _codeGenerationEngine = new Engine();
            _modelDefinition = _codeGenerationEngine.GenerateModelDefinition(project);
            Classes = _modelDefinition.ClassDefinitions.Select(cd => new ModelClassDefinitionViewModel(cd)).ToList();
            GenerateClassesCommand = new RelayCommand(DoGenerateClasses);
        }
예제 #13
0
        /// <summary>
        /// Constructor that takes in the projects URL, grabs the work item store where
        /// the queries are found, as well as the specific project name
        /// </summary>
        /// <param name="tfsUrl"></param>
        /// <param name="projectName"></param>
        public TfsHelperFunctions(string tfsUrl, string projectName)
        {
            _coll = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
                new Uri(tfsUrl));

            Store = new WorkItemStore(_coll);

            MyProject = Store.Projects[projectName];

            QueryHierarchy = Store.Projects[projectName].QueryHierarchy;
        }
 public WorkItemWrite(TfsTeamProjectCollection tfs, Project destinationProject)
 {
     this.tfs = tfs;
     projectName = destinationProject.Name;
     this.destinationProject = destinationProject;
     store = new WorkItemStore(tfs, WorkItemStoreFlags.BypassRules);
     queryCol = store.Projects[destinationProject.Name].QueryHierarchy;
     workItemTypes = store.Projects[destinationProject.Name].WorkItemTypes;
     itemMap = new Hashtable();
     itemMapCIC = new Hashtable();
 }
예제 #15
0
파일: Project.cs 프로젝트: xul8tr/Qwiq
 internal Project(Tfs.Project project)
     : base(
         project.Guid,
         project.Name,
         project.Uri,
         new Lazy <IWorkItemTypeCollection>(() => new WorkItemTypeCollection(project.WorkItemTypes)),
         new Lazy <IWorkItemClassificationNodeCollection <int> >(() => WorkItemClassificationNodeCollectionBuilder.Build(project.AreaRootNodes)),
         new Lazy <IWorkItemClassificationNodeCollection <int> >(() => WorkItemClassificationNodeCollectionBuilder.Build(project.IterationRootNodes))
         )
 {
     Id = project.Id;
 }
예제 #16
0
        private WorkItem CreateTask(Project project, string taskTitle, string iterationPath)
        {
            // Create the tasks
            var taskType = project.WorkItemTypes["Task"];
            var task = new WorkItem(taskType);
            task.IterationPath = iterationPath;
            //task.State = "New";

            task.Title = taskTitle;
            task.Save();

            AddLog("created task - " + task.Id.ToString());
            return task;
        }
예제 #17
0
        public static void ImportToCurrituck(Microsoft.TeamFoundation.WorkItemTracking.Client.Project VSTSProj, string witdFile)
        {
            try
            {
                /* first check if the FORM section has Layout in this.. this is possible if the customer
                 * doesn't modifies the generated WITD in Analyze phase
                 */
                Display.StartProgressDisplay(UtilityMethods.Format(
                                                 VSTSResource.VstsSchemaImporting, witdFile));
                string witDefinition;
                using (StreamReader stream = new StreamReader(witdFile))
                {
                    witDefinition = stream.ReadToEnd();
                }

                WorkItemTypeCollection wits = VSTSProj.WorkItemTypes;
                Logger.Write(LogSource.WorkItemTracking, TraceLevel.Verbose, "Provisioning Work Item Type : {0}", witdFile);

                wits.Import(witDefinition);
            }
            // Any changes made in this catch block should be reproduced in the below catch block too;
            // This is to get rid of the nonclscompliant message from FxCop
            catch (XmlSchemaValidationException e)
            {
                Logger.WriteException(LogSource.WorkItemTracking, e);
                string errMsg = UtilityMethods.Format(
                    VSTSResource.VstsWITValidationFailed, witdFile,
                    e.LineNumber, e.LinePosition, e.Message);
                Common.ConverterMain.MigrationReport.WriteIssue(string.Empty, errMsg, string.Empty, null,
                                                                IssueGroup.Witd.ToString(), ReportIssueType.Critical);

                throw new ConverterException(errMsg, e);
            }
            catch (Exception e)
            {
                Logger.WriteException(LogSource.WorkItemTracking, e);
                string errMsg = UtilityMethods.Format(
                    VSTSResource.VstsWITProvisionFailed, witdFile, e.Message);
                Common.ConverterMain.MigrationReport.WriteIssue(string.Empty,
                                                                errMsg, string.Empty, null, IssueGroup.Witd.ToString(), ReportIssueType.Critical);

                throw new ConverterException(errMsg, e);
            }
            finally
            {
                Logger.Write(LogSource.WorkItemTracking, TraceLevel.Verbose, "Work Item Type Provisioning Done : {0}", witdFile);
                Display.StopProgressDisplay();
            }
        } // end of ImportToCurrituck
예제 #18
0
        // TFSの情報を取得する
        void GetTfsProject( string collenctionName, string projectName )
        {
            // TFS内の、コレクションのリストを取得する
            ReadOnlyCollection<CatalogNode> collectionNodes =
                configurationServer.CatalogNode.QueryChildren(
                    new[] { CatalogResourceTypes.ProjectCollection },
                    false, CatalogQueryOptions.None );

            // コレクションのリストから、必要なコレクションを取得する
            foreach ( CatalogNode collectionNode in collectionNodes ) {
                Guid collectionId =
                    new Guid( collectionNode.Resource.Properties["InstanceId"] );
                TfsTeamProjectCollection teamProjectCollection =
                    configurationServer.GetTeamProjectCollection( collectionId );
                Console.WriteLine( "Collection: " + teamProjectCollection.Name );

                // 登録するチームコレクションでフィルタする
                if ( teamProjectCollection.Name != collenctionName ) {
                    continue;
                }

                // コレクション内の、チームプロジェクトのリストを取得する
                ReadOnlyCollection<CatalogNode> projectNodes =
                    collectionNode.QueryChildren(
                        new[] { CatalogResourceTypes.TeamProject },
                        false, CatalogQueryOptions.None );

                // チームプロジェクトのリストから、必要なプロジェクトを取得する
                foreach ( CatalogNode projectNode in projectNodes ) {
                    Console.WriteLine( " Team Project: " +
                        projectNode.Resource.DisplayName );

                    // 登録するプロジェクトでフィルタする
                    if ( projectNode.Resource.DisplayName != projectName ) {
                        continue;
                    }

                    // チームプロジェクトを取得する
                    WorkItemStore workItemStore =
                        teamProjectCollection.GetService<WorkItemStore>();
                    teamProject =
                        workItemStore.Projects[projectNode.Resource.DisplayName];

                    return;
                }
            }

            throw new Exception( "プロジェクトがありません" );
        }
        public bool DeleteQueryItem(TfsTeamProjectCollection tfsTeamProjectCollection, Project teamProject, Guid queryItemId)
        {
            this.Logger().Trace("DeleteQueryItem");

            var workItemStore = GetWorkItemStore(tfsTeamProjectCollection);
            var queryHierarchy = workItemStore.GetQueryHierarchy(teamProject);
            var queryItem = queryHierarchy.Find(queryItemId);

            if (queryItem == null)
                return false;

            queryItem.Delete();
            queryHierarchy.Save();
            return true;
        }
        public bool TryAddNewQueryFolder(out QueryFolder childFolder, TfsTeamProjectCollection tfsTeamProjectCollection, Project teamProject, Guid parentFolderId)
        {
            try
            {
                childFolder = _teamPilgrimTfsService.AddNewQueryFolder(tfsTeamProjectCollection, teamProject, parentFolderId);
                return true;
            }
            catch (Exception ex)
            {
                LastException = ex;
            }

            childFolder = null;
            return false;
        }
        public WorkItemQueryFolderModel(IWorkItemQueryCommandModel workItemQueryCommandModel, Project project, int depth, QueryFolder queryFolder, IEnumerable<WorkItemQueryChildModel> childQueryItemViewModels, QueryFolderTypeEnum? queryFolderType)
            : base(workItemQueryCommandModel, depth)
        {
            Project = project;
            QueryFolder = queryFolder;
            QueryFolderType = queryFolderType;

            var childQueryItemViewModelsArray = childQueryItemViewModels.ToArray();

            foreach (var workItemQueryChildModel in childQueryItemViewModelsArray)
            {
                workItemQueryChildModel.ParentQueryFolder = this;
            }

            QueryItems = new ObservableCollection<WorkItemQueryChildModel>(childQueryItemViewModelsArray);
        }
예제 #22
0
        private TeamCapacity QuerryCapacity(Project project, TeamFoundationTeam team, Iteration iter)
        {
            if (project == null || team == null || iter == null)
            {
                return(null);
            }

            var members = QuerryCapacity(project.Guid, team.Identity.TeamFoundationId, iter.Id);

            if (members == null)
            {
                return(null);
            }

            return(new TeamCapacity(project, team, iter, members));
        }
        public bool TryCloneQueryDefinition(out IBuildDefinition buildDefinition, TfsTeamProjectCollection collection, Project project, IBuildDefinition definition)
        {
            try
            {
                buildDefinition = _teamPilgrimTfsService.CloneBuildDefinition(collection, project.Name, definition);
                return true;
            }
            catch (Exception ex)
            {
                this.Logger().DebugException(ex);
                LastException = ex;
            }

            buildDefinition = null;
            return false;
        }
        public QueryFolder AddNewQueryFolder(TfsTeamProjectCollection teamProjectCollection, Project teamProject, Guid parentFolderId)
        {
            this.Logger().Trace("AddNewQueryFolder");

            var workItemStore = GetWorkItemStore(teamProjectCollection);
            var queryHierarchy = workItemStore.GetQueryHierarchy(teamProject);
            var loadedParentFolder = queryHierarchy.Find(parentFolderId) as QueryFolder;

            var queryFolder = new QueryFolder("New Folder");

            Debug.Assert(loadedParentFolder != null, "loadedParentFolder != null");
            loadedParentFolder.Add(queryFolder);

            queryHierarchy.Save();

            return queryFolder;
        }
예제 #25
0
        public ProjectDetails(Project project)
        {
            _project = project;
            Id = project.Id;
            Name = project.Name;
            Path = "$/" + Name; // TODO: Check this is correct

            WorkItemTypes = new List<WorkItemType>();
            WorkItemTypesAsStrings = new List<string>();
            Users = new List<string>();
            Iterations = new List<IterationSummary>();
            StoredQueries = new List<StoredQuerySummary>();

            AddWorkItemTypes();
            AddWorkItemTypesAsStrings();
            AddIterations();
            AddStoredQueries();
        }
예제 #26
0
        internal static TfsCategory CreateProject(Project project)
        {
            var areaPaths = new List<TfsCategory>();

            foreach (Node area in project.AreaRootNodes)
            {
                areaPaths.Add(new TfsCategory(area.Path, area.Path, new TfsCategory[0], CategoryTypes.AreaPath));

                foreach (Node item in area.ChildNodes)
                {
                    areaPaths.Add(new TfsCategory(item.Path, item.Path, new TfsCategory[0], CategoryTypes.AreaPath));
                }
            }

            return new TfsCategory(project.Name,
                project.Name,
                areaPaths.ToArray(),
                CategoryTypes.Project);
        }
예제 #27
0
        public bool Connect()
        {
            try
            {
                //
                //Trace.Write(WindowsIdentity.GetCurrent().Name);

                server = new TeamFoundationServer(ServerName, Credentials);
                store = server.GetService(typeof(WorkItemStore)) as WorkItemStore;
                project = store.Projects[ProjectName];

                //TODO: Validar conexão
                return true;
            }
            catch (Exception xa)
            {
                throw xa;
            }
        }
예제 #28
0
        private static void ProvisionProjectFeatures(IVssRequestContext context, Microsoft.TeamFoundation.WorkItemTracking.Client.Project project, StreamWriter logFile)
        {
            // Get the Feature provisioning service ("Configure Features")
            var projectFeatureProvisioningService = context.GetService <ProjectFeatureProvisioningService>();

            if (!projectFeatureProvisioningService.GetFeatures(context, project.Uri.ToString()).Where(f => (f.State == ProjectFeatureState.NotConfigured && !f.IsHidden)).Any())
            {
                // When the team project is already fully or partially configured, report it
                Console.WriteLine("\t{0}: Project is up to date.", project.Name);
                logFile.WriteLine(">>> Team Project is now already up to date");
            }
            else
            {
                // Find valid process templates
                var projectFeatureProvisioningDetails = projectFeatureProvisioningService.ValidateProcessTemplates(context, project.Uri.ToString());

                var validProcessTemplateDetails = projectFeatureProvisioningDetails.Where(d => d.IsValid);

                switch (validProcessTemplateDetails.Count())
                {
                case 0:
                    Console.WriteLine("\t{0}: No valid process templates found.", project.Name);
                    logFile.WriteLine(">>> No valid process templates found, the team project cannot be configured/upgraded automatically to adopt the latest features.");
                    break;

                case 1:
                    var projectFeatureProvisioningDetail = projectFeatureProvisioningDetails.ElementAt(0);
                    Console.WriteLine(">>> Upgrading Team Project with template " + projectFeatureProvisioningDetail.ProcessTemplateDescriptorName);
                    logFile.WriteLine(">>> Upgrading Team Project with template " + projectFeatureProvisioningDetail.ProcessTemplateDescriptorName);
                    ProvisionProject(context, project, projectFeatureProvisioningService, projectFeatureProvisioningDetail);
                    break;

                default:
                    // Try to upgrade using the recommended process template
                    var newRecommendedTemplate = validProcessTemplateDetails.FirstOrDefault(ptd => ptd.IsRecommended);
                    Console.WriteLine(">>> Multiple valid process templates found. Upgrading Team Project with recommended template " + newRecommendedTemplate.ProcessTemplateDescriptorName);
                    logFile.WriteLine(">>> Multiple valid process templates found. Upgrading Team Project with recommended template " + newRecommendedTemplate.ProcessTemplateDescriptorName);
                    ProvisionProject(context, project, projectFeatureProvisioningService, newRecommendedTemplate);
                    break;
                }
            }
        }
예제 #29
0
        static QueryDefinition GetWorkItemQueryByName(WorkItemStore workItemStore, Project project, string queryPath)
        {
            var hierarchy = workItemStore.GetQueryHierarchy(project);

            foreach (var item in hierarchy)
            {
                if (item.Path == queryPath && item is QueryDefinition)
                    return item as QueryDefinition;

                if (!(item is QueryFolder))
                    continue;

                var query = GetWorkItemQueryByName(item as QueryFolder, queryPath);

                if (query != null)
                    return query;
            }

            return null;
        }
예제 #30
0
        private void ConnectToTfs(CommandLineOptions options)
        {
            Log(string.Format(CultureInfo.InvariantCulture, "Connecting to Tfs at {0}...", options.TfsServerUrl));

            // Connect to Team Foundation Server
            Uri tfsUri = new Uri(options.TfsServerUrl);
            _teamProjectCollection = new TfsTeamProjectCollection(tfsUri);

            _linkService = _teamProjectCollection.GetService<TswaClientHyperlinkService>();
            _workItemStore = _teamProjectCollection.GetService<WorkItemStore>();
            _tfsProject = _workItemStore.Projects[options.TfsProject];

            if (options.TfsQuery == null)
            {
                _tfsQueryFolder = _tfsProject.QueryHierarchy[options.TfsQueryHierarchy] as QueryFolder;
                _tfsQueryItem = _tfsQueryFolder[options.TfsQueryName];
            }
            else
            {
                _tfsQueryItem = options.TfsQuery;
            }
        }
예제 #31
0
        private static void FeedWorkItemData(ICollection <WorkItemDefinition> workItemDefinitionCollection,
                                             TfsTeamProjectCollection tpc, string projectName)
        {
            WorkItemStore wis = tpc.GetService <WorkItemStore>();

            Microsoft.TeamFoundation.WorkItemTracking.Client.Project project = wis.Projects[projectName];

            foreach (WorkItemType wit in project.WorkItemTypes)
            {
                WorkItemDefinition witDefinition = new WorkItemDefinition()
                {
                    Name = wit.Name, Description = wit.Description
                };

                IEnumerable <Category> categories = project.Categories.Where(x => x.WorkItemTypes.Contains(wit));
                foreach (Category item in categories)
                {
                    witDefinition.Categories.Add(item.Name);
                }

                FieldDefinition systemState = wit.FieldDefinitions.TryGetByName("System.State");
                foreach (string allowedValue in systemState.AllowedValues)
                {
                    int stateCount = wis.QueryCount("Select System.Id From WorkItems Where System.TeamProject = '"
                                                    + projectName
                                                    + "' And System.WorkItemType = '"
                                                    + witDefinition.Name
                                                    + "' And System.State = '"
                                                    + allowedValue
                                                    + "'");

                    witDefinition.StateCollection.Add(allowedValue, stateCount);
                }
                workItemDefinitionCollection.Add(witDefinition);
            }
        }
        private static void RecurseIterations(NodeCollection sourceNodes, NodeInfo destinationRootNodeInfo, NodeCollection destinationRootNodes, Project destinationWitProject)
        {
            foreach (Node sourceIteration in sourceNodes)
            {
                NodeInfo destIterationNodeInfo = null;
                Node destIterationNode = null;

                if (destinationRootNodes.Cast<Node>().FirstOrDefault(n => n.Name == sourceIteration.Name) != null)
                {
                    destIterationNode = destinationRootNodes.Cast<Node>().FirstOrDefault(n => n.Name == sourceIteration.Name);
                    destIterationNodeInfo = _destinationStructureService.GetNode(destIterationNode.Uri.ToString());

                    _destinationIterationNodes.Add(destIterationNode);
                }

                if (destIterationNodeInfo == null) // node doesn't exist
                {
                    string newAreaNodeUri = _destinationStructureService.CreateNode(sourceIteration.Name, destinationRootNodeInfo.Uri);
                    destIterationNodeInfo = _destinationStructureService.GetNode(newAreaNodeUri);
                    destIterationNode = FindIterationNode(destinationWitProject, destIterationNodeInfo.Path);

                    _destinationIterationNodes.Add(destIterationNode);
                }

                if (sourceIteration.ChildNodes.Count > 0)
                {
                    RecurseIterations(sourceIteration.ChildNodes, destIterationNodeInfo, destIterationNode.ChildNodes, destinationWitProject);
                }
            }
        }
        private static Node GetRootIterationNodeByName(Project project, string name)
        {
            Node rootNode = null;

            bool areaFound = false;
            while (!areaFound)
            {
                try
                {
                    project.Store.RefreshCache(true);
                    project.Store.SyncToCache();

                    Node tempNode = project.Store.Projects[project.Name].IterationRootNodes[name];
                    rootNode = tempNode;  // if it isn't found an exception is thrown never getting to this.
                    areaFound = true;
                }
                catch (Exception ex)
                {
                    System.Threading.Thread.Sleep(1000);
                    areaFound = false;
                }
            }
            return rootNode;
        }
        private static Node FindIterationNode(Project project, string path)
        {
            path = path.Substring(1); // remove leading //

            List<string> pathParts = path.Split('\\').ToList();
            string projectName = pathParts[0];
            pathParts.RemoveAt(0); // remove the project name from the path parts
            pathParts.RemoveAt(0); // remove the word Iteration
            string rootIterationNodeName = pathParts[0];
            pathParts.RemoveAt(0); // remove the root node name

            Node currentNode = GetRootIterationNodeByName(project, rootIterationNodeName);

            for (int index = 0; index < pathParts.Count; index++)
            {
                bool iterationFound = false;
                while (!iterationFound)
                {
                    try
                    {
                        project.Store.RefreshCache(true);
                        project.Store.SyncToCache();

                        string nodeName = pathParts[index];

                        Node tempNode = currentNode.ChildNodes[nodeName];
                        currentNode = tempNode;  // if it isn't found an exception is thrown never getting to this.
                        iterationFound = true;
                    }
                    catch (Exception ex)
                    {
                        System.Threading.Thread.Sleep(1000);
                        currentNode = GetRootIterationNodeByName(project, rootIterationNodeName);
                        iterationFound = false;
                        break;
                    }
                }
            }

            return currentNode;
        }
        private static string CreateAndCollectInfoForDestinationAreaAndIterations(ITestManagementTeamProject destinationTestProject, Project sourceWitProject)
        {
            if (_destinationStructureService == null)
            {
                return "******** Couldn't connect to the Destination Structure Service, cannot create Areas or Iterations" + Environment.NewLine;
            }

            string rootAreaNodePath = string.Format("\\{0}\\Area", destinationTestProject.TeamProjectName);
            NodeInfo areaPathRootInfo = _destinationStructureService.GetNodeFromPath(rootAreaNodePath);
            _destinationAreaNodes.Clear();

            RecurseAreas(sourceWitProject.AreaRootNodes, areaPathRootInfo, destinationTestProject.WitProject.AreaRootNodes, destinationTestProject.WitProject);

            string rootIterationNodePath = string.Format("\\{0}\\Iteration", destinationTestProject.TeamProjectName);
            NodeInfo iterationPathRootInfo = _destinationStructureService.GetNodeFromPath(rootIterationNodePath);
            _destinationIterationNodes.Clear();

            RecurseIterations(sourceWitProject.IterationRootNodes, iterationPathRootInfo, destinationTestProject.WitProject.IterationRootNodes, destinationTestProject.WitProject);

            return string.Empty;
        }
예제 #36
0
 public void NewQueryDefinition(Project project, QueryFolder parent)
 {
     parent = parent ?? WorkItemTrackingDocumentService.GetDefaultParent(project, false);
     _workItemTrackingPackage.Value.NewQuery(project.Name, parent);
 }
예제 #37
0
 private TfsGroupNode TransformIterations(Project p)
 {
     return new TfsGroupNode()
     {
         Children = Transform(p.IterationRootNodes),
         Name = p.Name,
         Uri = p.Uri,
         Id = p.Id,
     };
 }
예제 #38
0
 private static void ProvisionProject(IVssRequestContext context, Microsoft.TeamFoundation.WorkItemTracking.Client.Project project, ProjectFeatureProvisioningService projectFeatureProvisioningService, IProjectFeatureProvisioningDetails projectFeatureProvisioningDetail)
 {
     projectFeatureProvisioningService.ProvisionFeatures(context, project.Uri.ToString(), projectFeatureProvisioningDetail.ProcessTemplateDescriptorId);
 }
예제 #39
0
 internal ProjectProxy(Tfs.Project project)
 {
     _project = project;
 }
예제 #40
0
        private static void RunFeatureEnablement(IVssDeploymentServiceHost deploymentServiceHost, Microsoft.TeamFoundation.WorkItemTracking.Client.Project project, Guid instanceId, StreamWriter file)
        {
            try
            {
                Console.WriteLine("Running feature enablement for '{0}'", project.Name);

                using (IVssRequestContext context = CreateServicingContext(deploymentServiceHost, instanceId))
                {
                    ProvisionProjectFeatures(context, project, file);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Feature enablement failed for project '{0}': see log for details.", project.Name);
                file.WriteLine(">>> Feature enablement failed for project '{0}': {1}", project.Name, ex);
            }
        }
예제 #41
0
        private Dictionary <string, IterationInfo> LoadIterations(TfsTeamProjectCollection tfs, Project project)
        {
            var css = tfs.GetService <ICommonStructureService4>();

            var structures     = css.ListStructures(project.Uri.ToString());
            var iterations     = structures.First(n => n.StructureType.Equals("ProjectLifecycle"));
            var iterationsTree = css.GetNodesXml(new[] { iterations.Uri }, true);

            var result = new Dictionary <string, IterationInfo>();

            BuildIterationTree(result, project.IterationRootNodes, css);

            return(result);
        }
 public void NewQueryDefinition(Project project, QueryFolder parent)
 {
     parent = parent ?? WorkItemTrackingDocumentService.GetDefaultParent(project, false);
     _workItemTrackingPackage.Value.NewQuery(project.Name, parent);
 }