public WorkItemClassificationNode CreateIteration() { Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id; string newIterationName = "New iteration " + Guid.NewGuid(); WorkItemClassificationNode node = new WorkItemClassificationNode() { Name = newIterationName, StructureType = TreeNodeStructureType.Iteration, Attributes = new Dictionary <string, Object>() { { "startDate", DateTime.Today }, { "finishDate", DateTime.Today.AddDays(7) }, } }; // Get a client VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>(); // Create the new iteration WorkItemClassificationNode result = workItemTrackingClient.CreateOrUpdateClassificationNodeAsync( node, projectId.ToString(), TreeStructureGroup.Iterations).Result; // Show the new node ShowNodeTree(result); // Save the new iteration for use in a later sample Context.SetValue <string>("$newIterationName", node.Name); Context.SetValue <Guid>("$newIterationProjectId", projectId); return(result); }
public string CreateIteration(string project, string name, string startDate, string finishDate) { IDictionary <string, Object> dict = new Dictionary <string, Object>(); dict.Add("startDate", startDate); dict.Add("finishDate", finishDate); WorkItemClassificationNode node = new WorkItemClassificationNode() { Name = name, StructureType = TreeNodeStructureType.Iteration, Attributes = dict }; using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(_uri, _credentials)) { try { WorkItemClassificationNode result = workItemTrackingHttpClient.CreateOrUpdateClassificationNodeAsync(node, project, TreeStructureGroup.Iterations, name).Result; return("success"); } catch (AggregateException ex) { return(ex.InnerException.ToString()); } } }
public static async Task <WorkItemClassificationNode> CreateAreaAsync(this WorkItemTrackingHttpClient source, NodePath areaPath, CancellationToken cancellationToken) { //Get the parent area, if any if (areaPath.Parent != null) { var parentArea = await source.GetAreaAsync(areaPath.Parent, false, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); if (parentArea == null) { parentArea = await source.CreateAreaAsync(areaPath.Parent, cancellationToken).ConfigureAwait(false); } } ; var newArea = new WorkItemClassificationNode() { Name = areaPath.Name }; newArea = await source.CreateOrUpdateClassificationNodeAsync(newArea, areaPath.Project, TreeStructureGroup.Areas, path : areaPath.Parent?.RelativePath, cancellationToken : cancellationToken).ConfigureAwait(false); Logger.Debug($"Created area '{areaPath}' with Id {newArea.Id}"); return(newArea); }
private void SaveClassificationNodesRecursive(Guid projectId, WorkItemClassificationNode classificationNode, TreeStructureGroup structureGroup, string pathToParent = null) { try { var result = workClient.CreateOrUpdateClassificationNodeAsync( classificationNode, projectId.ToString(), structureGroup, pathToParent).Result; Logger.Info($"{GetType()} Saved type {structureGroup} '{pathToParent}\\{classificationNode.Name}'"); } catch (Exception) { // Intentionally eating the e Logger.Error($"{GetType()} Failed saving type {structureGroup} '{pathToParent}\\{classificationNode.Name}', does it already exist?"); } if (classificationNode.HasChildren != true) { return; } var newPathToParent = $"{pathToParent}\\{classificationNode.Name}"; foreach (var classificationNodeChild in classificationNode.Children) { SaveClassificationNodesRecursive(projectId, classificationNodeChild, structureGroup, newPathToParent); } }
public async static Task <WorkItemClassificationNode> CreateAreaPathAsync(WorkItemTrackingHttpClient client, string projectId, string areaPath) { return(await RetryHelper.RetryAsync(async() => { return await client.CreateOrUpdateClassificationNodeAsync(new WorkItemClassificationNode() { Name = areaPath.Contains("\\") ? areaPath.Split("\\").Last() : areaPath, StructureType = TreeNodeStructureType.Area, }, projectId, TreeStructureGroup.Areas, areaPath.Replace(projectId, "").Replace(areaPath.Contains("\\") ? areaPath.Split("\\").Last() : areaPath, "")); }, 5)); }
public WorkItemClassificationNode CreateArea(string project, string name) { WorkItemClassificationNode node = new WorkItemClassificationNode() { Name = name, StructureType = TreeNodeStructureType.Area }; VssConnection connection = new VssConnection(_uri, _credentials); WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient <WorkItemTrackingHttpClient>(); WorkItemClassificationNode result = workItemTrackingHttpClient.CreateOrUpdateClassificationNodeAsync(node, project, TreeStructureGroup.Areas, "").Result; return(result); }
public string CreateArea(string project, string path, string name) { WorkItemClassificationNode node = new WorkItemClassificationNode() { Name = name, StructureType = TreeNodeStructureType.Area }; using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(_uri, _credentials)) { WorkItemClassificationNode result = workItemTrackingHttpClient.CreateOrUpdateClassificationNodeAsync(node, project, TreeStructureGroup.Areas, path).Result; } return("success"); }
public WorkItemClassificationNode CreateArea() { Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id; String newAreaName = "My new area " + Guid.NewGuid(); WorkItemClassificationNode node = new WorkItemClassificationNode() { Name = newAreaName, StructureType = TreeNodeStructureType.Area, Children = new List <WorkItemClassificationNode>() { new WorkItemClassificationNode() { Name = "Child 1" }, new WorkItemClassificationNode() { Name = "Child 2" } } }; // Get a client VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>(); // Create the new area WorkItemClassificationNode result = workItemTrackingClient.CreateOrUpdateClassificationNodeAsync( node, projectId.ToString(), TreeStructureGroup.Areas).Result; // Show the new node ShowNodeTree(result); // Save the new area for use in a later sample Context.SetValue <string>("$newAreaName", node.Name); Context.SetValue <Guid>("$newAreaProjectId", projectId); return(result); }
public WorkItemClassificationNode CreateIteration(string project, string name) { //IDictionary<string, Object> dict = new Dictionary<string, Object>(); //dict.Add("startDate", startDate); //dict.Add("finishDate", finishDate); WorkItemClassificationNode node = new WorkItemClassificationNode() { Name = name, StructureType = TreeNodeStructureType.Iteration //Attributes = dict }; VssConnection connection = new VssConnection(_uri, _credentials); WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient <WorkItemTrackingHttpClient>(); WorkItemClassificationNode result = workItemTrackingHttpClient.CreateOrUpdateClassificationNodeAsync(node, project, TreeStructureGroup.Iterations, "").Result; return(result); }
public static async Task <WorkItemClassificationNode> CreateIterationAsync(this WorkItemTrackingHttpClient source, NodePath nodePath, DateRange dates, CancellationToken cancellationToken) { //Get the parent node, if any if (nodePath.Parent != null) { var parent = await source.GetIterationAsync(nodePath.Parent, false, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); if (parent == null) { parent = await source.CreateIterationAsync(nodePath.Parent, DateRange.Empty, cancellationToken).ConfigureAwait(false); } } ; var newItem = new WorkItemClassificationNode() { Name = nodePath.Name }; if (dates != DateRange.Empty) { newItem.SetStartDate(dates.Start); newItem.SetFinishDate(dates.End); } ; newItem = await source.CreateOrUpdateClassificationNodeAsync(newItem, nodePath.Project, TreeStructureGroup.Iterations, path : nodePath.Parent?.RelativePath, cancellationToken : cancellationToken).ConfigureAwait(false); if (dates != DateRange.Empty) { Logger.Debug($"Created iteration '{newItem.Name}' with dates {dates} and Id {newItem.Id}"); } else { Logger.Debug($"Created iteration '{newItem.Name}' with Id {newItem.Id}"); } return(newItem); }
private static WorkItemClassificationNode AddIteration(Guid projectId, string iterationName, DateTime startDate, DateTime endDate, string path = null) { WorkItemClassificationNode iteration = new WorkItemClassificationNode { Name = iterationName, StructureType = TreeNodeStructureType.Iteration }; iteration.Attributes = new Dictionary <string, object> { { "startDate", startDate }, { "finishDate", endDate } }; //add the iteration to the project WorkItemTrackingHttpClient workItemTrackingClient = v.GetClient <WorkItemTrackingHttpClient>(); var x = workItemTrackingClient.CreateOrUpdateClassificationNodeAsync(iteration, projectId, TreeStructureGroup.Iterations, path).Result; return(x); }
public async static Task <WorkItemClassificationNode> CreateIterationAsync(WorkItemTrackingHttpClient client, string projectId, string iteration, DateTime?startDate, DateTime?endDate) { return(await RetryHelper.RetryAsync(async() => { var attrs = new Dictionary <string, object>(); if (startDate.HasValue) { attrs.Add("startDate", startDate); } if (endDate.HasValue) { attrs.Add("finishDate", endDate); } return await client.CreateOrUpdateClassificationNodeAsync(new WorkItemClassificationNode() { Name = iteration.Contains("\\") ? iteration.Split("\\").Last() : iteration, StructureType = TreeNodeStructureType.Iteration, Attributes = attrs }, projectId, TreeStructureGroup.Iterations); }, 5)); }
//private string ConvertDanishLettersToEnglish(string project) //{ // var regex = new Regex("ø|Ø|æ|Æ|å|Å"); // var projectContainsAny = regex.IsMatch(project); // if (projectContainsAny) // { // project.Replace("ø", "o").Replace("Ø", "O").Replace("æ", "ae").Replace("Æ", "Ae").Replace("å", "aa").Replace("Å", "Aa"); // } // return project; //} private async Task CreateIterationIfNonExists(string project, Ticket ticket) { if (string.IsNullOrWhiteSpace(ticket.PlannedInVersion)) { return; } var iterations = await _workItemTrackingHttpClient.GetClassificationNodeAsync(project, TreeStructureGroup.Iterations, depth : 1); if (iterations.HasChildren == true) { var iteration = iterations.Children.FirstOrDefault(x => x.Name == ticket.PlannedInVersion); if (iteration == null) { var response = await _workItemTrackingHttpClient.CreateOrUpdateClassificationNodeAsync(new WorkItemClassificationNode { Name = ticket.PlannedInVersion }, project, TreeStructureGroup.Iterations); } } }