internal static async void GetWorkItemInfo(Visio.Shape shape, WorkItemShapeInfo.WorkItemShapeVersion version) { WorkItemShapeInfo shapeInfo = new WorkItemShapeInfo(shape); int id = 0; if (!int.TryParse(shapeInfo.ID, out id)) { MessageBox.Show($"Invalid WorkItem ID: ({shapeInfo.ID})"); return; } var result = await VNC.AZDO.Helper.QueryWorkItemInfoById(shapeInfo.Organization, id); if (result.Count == 0) { MessageBox.Show($"Cannot find WorkItem ID: ({shapeInfo.ID})"); return; } shapeInfo.InitializeFromWorkItem(result[0]); // NOTE(crhodes) // Go add the bugs int bugs = await VNC.AZDO.Helper.QueryRelatedBugsById(shapeInfo.Organization, int.Parse(shapeInfo.ID)); shapeInfo.RelatedBugs = bugs.ToString(); shapeInfo.PopulateShapeDataFromInfo(shape, version); VisioHelper.DisplayInWatchWindow($"{shapeInfo}"); }
private static async void AddNewWorkItemRevisionShapeToPage(Visio.Page page, Visio.Master linkMaster, WorkItem workItem, Point insertionPoint, WorkItemShapeInfo relatedShape, WorkItemShapeInfo.WorkItemShapeVersion version) { try { Visio.Shape newWorkItemShape = page.Drop(linkMaster, insertionPoint.X, insertionPoint.Y); WorkItemShapeInfo shapeInfo = new WorkItemShapeInfo(newWorkItemShape); shapeInfo.InitializeFromWorkItemRevision(workItem, int.Parse(relatedShape.ID)); //int bugs = await VNC.AZDO.Helper.QueryRelatedBugsById(shapeInfo.Organization, int.Parse(shapeInfo.ID)); //shapeInfo.RelatedBugs = bugs.ToString(); shapeInfo.PopulateShapeDataFromInfo(newWorkItemShape, version); } catch (Exception ex) { VisioHelper.DisplayInWatchWindow($"{workItem.Id} - {ex}"); } }
internal static async void AddLinkedWorkItems(Visio.Application app, Visio.Page page, Visio.Shape shape, string shapeName, WorkItemShapeInfo.WorkItemShapeVersion version) { if (!VerifyRequiredStencils(app)) { return; } WorkItemShapeInfo activeShapeWorkItemInfo = new WorkItemShapeInfo(shape); int id; if (int.TryParse(activeShapeWorkItemInfo.ID, out id)) { } else { MessageBox.Show($"Cannot parse ({activeShapeWorkItemInfo.ID}) as WorkItemID"); return; } int relatedLinkCount; if (int.TryParse(activeShapeWorkItemInfo.RelatedLinkCount, out relatedLinkCount)) { } else { MessageBox.Show($"Cannot parse ({activeShapeWorkItemInfo.RelatedLinkCount}) as RelatedLinkCount"); return; } var result = await VNC.AZDO.Helper.QueryWorkItemLinks(activeShapeWorkItemInfo.Organization, id, relatedLinkCount); if (result.Count > 0) { Point initialPosition = GetPosition(shape); Point insertionPoint = initialPosition; string stencilName = "Azure DevOps.vssx"; Visio.Document linkStencil; Visio.Master linkMaster = null; try { linkStencil = app.Documents[stencilName]; try { linkMaster = linkStencil.Masters[shapeName]; } catch (Exception ex) { VisioHelper.DisplayInWatchWindow(string.Format(" Cannot find Master named:>{0}<", shapeName)); } } catch (Exception ex) { VisioHelper.DisplayInWatchWindow(string.Format(" Cannot find open Stencil named:>{0}<", stencilName)); } // TODO(crhodes) // Figure out how to get size of shape from master. // HACK(crhodes) // .25 is for Link counts double height = version == WorkItemShapeInfo.WorkItemShapeVersion.V1 ? 0.375 : 0.475; WorkItemOffsets workItemOffsets = new WorkItemOffsets(initialPosition, height: height, padX: 0.25, padY: 0.05); foreach (var linkedWorkItem in result) { // NOTE(crhodes) // This includes the current shape. Do not add it. // May always be first one. Maybe loop counter if (linkedWorkItem.Id == id) { continue; } VisioHelper.DisplayInWatchWindow($"{linkedWorkItem.Id} {linkedWorkItem.Fields["System.Title"]}"); insertionPoint = AZDOPageLayout.CalculateInsertionPointLinkedWorkItems(initialPosition, linkedWorkItem, activeShapeWorkItemInfo, workItemOffsets); AddNewWorkItemShapeToPage(page, linkMaster, linkedWorkItem, insertionPoint, activeShapeWorkItemInfo, version); } } VisioHelper.DisplayInWatchWindow($"{activeShapeWorkItemInfo}"); }