public WorkItemStore(EngineContext context, WorkItem workItem) : this(context) { //initialize tracker with initial work item var wrapper = new WorkItemWrapper(_context, workItem); //store event initiator identity _triggerIdentity = wrapper.ChangedBy; }
internal void TrackExisting(WorkItemWrapper workItemWrapper) { if (IsTracked(workItemWrapper)) { throw new InvalidOperationException($"Work item {workItemWrapper.Id} is already tracked"); } TrackNew(workItemWrapper); }
internal WorkItemRelationWrapperCollection(WorkItemWrapper workItem, IList <WorkItemRelation> relations) { _pivotWorkItem = workItem; _original = relations == null ? new List <WorkItemRelationWrapper>() : new List <WorkItemRelationWrapper>(relations.Select(relation => new WorkItemRelationWrapper(_pivotWorkItem, relation))); }
internal void TrackRevision(WorkItemWrapper workItemWrapper) { if (!tracked.ContainsKey(workItemWrapper.Id)) { // should never happen... throw new InvalidOperationException($"Work item {workItemWrapper.Id} was never loaded"); } tracked[workItemWrapper.Id].Revisions.Add(workItemWrapper.Rev, workItemWrapper); }
internal WorkItemRelationWrapperCollection(WorkItemWrapper workItem, IList <WorkItemRelation> relations) { _pivotWorkItem = workItem; _original = relations == null ? new List <WorkItemRelationWrapper>() : new List <WorkItemRelationWrapper>(relations.Select(relation => new WorkItemRelationWrapper(_pivotWorkItem, relation))); // do we need deep cloning? _current = new List <WorkItemRelationWrapper>(_original); }
internal WorkItemRelationWrapper(WorkItemWrapper item, string type, string url, string comment) { _item = item; _relation = new WorkItemRelation() { Rel = type, Url = url, Attributes = { { "comment", comment } } }; }
internal void TrackExisting(WorkItemWrapper workItemWrapper) { if (IsTracked(workItemWrapper)) { throw new InvalidOperationException($"Work item {workItemWrapper.Id} is already tracked"); } var t = new TrackedWrapper(workItemWrapper.Id.Value, workItemWrapper); tracked.Add(workItemWrapper.Id, t); }
internal WorkItemRelationWrapperCollection(WorkItemWrapper workItem, IList <WorkItemRelation> relations) { _pivotWorkItem = workItem; _original = relations == null ? new List <WorkItemRelationWrapper>() : relations.Where(relation => relation.Rel.StartsWith("System.LinkType")) .Select(relation => new WorkItemRelationWrapper(relation)) .ToList(); // do we need deep cloning? _current = new List <WorkItemRelationWrapper>(_original); }
internal void TrackRevision(WorkItemWrapper workItemWrapper) { if (tracked.TryGetValue(workItemWrapper.Id, out var value)) { value.Revisions.Add(workItemWrapper.Rev, workItemWrapper); } else { // should never happen... throw new InvalidOperationException($"Work item {workItemWrapper.Id} was never loaded"); } }
private static bool ChangeRecycleStatus(WorkItemWrapper workItem, RecycleStatus toRecycleStatus) { if ((toRecycleStatus == RecycleStatus.ToDelete && workItem.IsDeleted) || (toRecycleStatus == RecycleStatus.ToRestore && !workItem.IsDeleted)) { return(false); } var previousStatus = workItem.RecycleStatus; workItem.RecycleStatus = toRecycleStatus; var updated = previousStatus != workItem.RecycleStatus; workItem.IsDirty = updated || workItem.IsDirty; return(updated); }
public WorkItemWrapper(EngineContext context, WorkItemWrapper template, string type) { _context = context.Track(this); Id = new TemporaryWorkItemId(); _item = new WorkItem(); _item.Fields[CoreFieldRefNames.TeamProject] = template.TeamProject; _item.Fields[CoreFieldRefNames.WorkItemType] = type; _item.Fields[CoreFieldRefNames.Id] = Id.Value; Changes.Add(new JsonPatchOperation() { Operation = Operation.Test, Path = "/id", Value = Id }); }
public WorkItemWrapper(EngineContext context, WorkItemWrapper template, string type) { _context = context; Id = new TemporaryWorkItemId(_context.Tracker); _item = new WorkItem(); _item.Fields[CoreFieldRefNames.TeamProject] = template.TeamProject; _item.Fields[CoreFieldRefNames.WorkItemType] = type; _item.Fields[CoreFieldRefNames.Id] = Id.Value; _relationCollection = new WorkItemRelationWrapperCollection(this, _item.Relations); Changes.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/id", Value = Id.Value }); _context.Tracker.TrackNew(this); }
public WorkItemWrapper NewWorkItem(string workItemType) { var item = new WorkItem() { Fields = new Dictionary <string, object>() { { CoreFieldRefNames.WorkItemType, workItemType }, { CoreFieldRefNames.TeamProject, _context.ProjectId.ToString() } }, Relations = new List <WorkItemRelation>(), Links = new Microsoft.VisualStudio.Services.WebApi.ReferenceLinks() }; var wrapper = new WorkItemWrapper(_context, item); _context.Logger.WriteVerbose($"Made new workitem with temporary id {wrapper.Id.Value}"); //HACK string baseUriString = _context.Client.BaseAddress.AbsoluteUri; item.Url = $"{baseUriString}/_apis/wit/workitems/{wrapper.Id.Value}"; return(wrapper); }
public WorkItemWrapper NewWorkItem(string workItemType, string projectName = null) { // TODO check workItemType and projectName values by querying AzDO var item = new WorkItem { Fields = new Dictionary <string, object> { { CoreFieldRefNames.WorkItemType, workItemType }, { CoreFieldRefNames.TeamProject, projectName ?? _context.ProjectName } }, Relations = new List <WorkItemRelation>(), Links = new Microsoft.VisualStudio.Services.WebApi.ReferenceLinks() }; var wrapper = new WorkItemWrapper(_context, item); _context.Logger.WriteVerbose($"Made new workitem in {wrapper.TeamProject} with temporary id {wrapper.Id}"); //HACK string baseUriString = _clients.WitClient.BaseAddress.AbsoluteUri; item.Url = FormattableString.Invariant($"{baseUriString}/_apis/wit/workitems/{wrapper.Id}"); return(wrapper); }
internal void TrackNew(WorkItemWrapper workItemWrapper) { var t = new TrackedWrapper(workItemWrapper.Id.Value, workItemWrapper); tracked.Add(workItemWrapper.Id, t); }
internal WorkItemRelationWrapper(WorkItemWrapper item, WorkItemRelation relation) { _item = item; _relation = relation; }
internal TrackedWrapper(int id, WorkItemWrapper wrapper) { Id = id; Current = wrapper; }
public void AddRelatedLink(WorkItemWrapper item, string comment = null) { AddRelatedLink(item.Url, comment); }
public void AddChild(WorkItemWrapper child) { var r = new WorkItemRelationWrapper(child, CoreRelationRefNames.Children, child.Url, string.Empty); AddRelation(r); }
public void AddParent(WorkItemWrapper parent) { var r = new WorkItemRelationWrapper(parent, CoreRelationRefNames.Parent, parent.Url, string.Empty); AddRelation(r); }
internal EngineContext Track(WorkItemWrapper workItemWrapper) { wrappers.Add(workItemWrapper); return(this); }
public bool RestoreWorkItem(WorkItemWrapper workItem) { _context.Logger.WriteVerbose($"Mark workitem for Restire {workItem.Id}"); return(ChangeRecycleStatus(workItem, RecycleStatus.ToRestore)); }
public bool DeleteWorkItem(WorkItemWrapper workItem) { _context.Logger.WriteVerbose($"Mark workitem for Delete {workItem.Id}"); return(ChangeRecycleStatus(workItem, RecycleStatus.ToDelete)); }
internal bool IsTracked(WorkItemWrapper workItemWrapper) { return(tracked.ContainsKey(workItemWrapper.Id)); }
public WorkItemStore(EngineContext context, WorkItem workItem) : this(context) { //initialize tracker with initial work item _ = new WorkItemWrapper(_context, workItem); }