/// <summary> /// Consulta los elementos de trabajo y los transforma en una colección de tareas /// </summary> private TaskModelCollection QueryWorkItems(ProjectModel objProject, string strQuery) { Project objTfsProject = LoadProjectTfs(objProject); TaskModelCollection objColTasks = new TaskModelCollection(); // Carga las tareas del proyecto if (objTfsProject != null) { WorkItemStore objWorkItemStore = tfsTeamProject.GetService <WorkItemStore>(); WorkItemCollection objColWorkItems = objWorkItemStore.Query(strQuery); // Transforma los elementos de trabajo en tareas foreach (WorkItem objWorkItem in objColWorkItems) { TaskModel objTask = new TaskModel(); // Asigna los datos objTask.ID = objWorkItem.Id; objTask.Name = objWorkItem.Title; // GetWorkItemField(objWorkItem, CoreField.Title); objTask.Description = objWorkItem.Description; // GetWorkItemField(objWorkItem, CoreField.Description); objTask.IdIteration = objWorkItem.IterationId; // GetWorkItemField(objWorkItem, CoreField.IterationId).GetInt(); objTask.Project = objWorkItem.Project.Name; // GetWorkItemField(objWorkItem, CoreField.TeamProject); objTask.AssignedTo = GetWorkItemField(objWorkItem, CoreField.AssignedTo); objTask.DateUpdate = objWorkItem.ChangedDate; // GetWorkItemField(objWorkItem, CoreField.ChangedDate).GetDateTime(); objTask.UserUpdate = objWorkItem.ChangedBy; // GetWorkItemField(objWorkItem, CoreField.ChangedBy); objTask.DateNew = objWorkItem.CreatedDate; // GetWorkItemField(objWorkItem, CoreField.CreatedDate).GetDateTime(); objTask.UserNew = objWorkItem.CreatedBy; // GetWorkItemField(objWorkItem, CoreField.CreatedBy); objTask.State = objWorkItem.State; // GetWorkItemField(objWorkItem, CoreField.State); objTask.Tags = objWorkItem.Tags; // GetWorkItemField(objWorkItem, CoreField.Tags); objTask.Type = objWorkItem.Type.ToString(); // GetWorkItemField(objWorkItem, CoreField.WorkItemType); objTask.DateAuthorized = objWorkItem.AuthorizedDate; // GetWorkItemField(objWorkItem, CoreField.AuthorizedDate).GetDateTime(); objTask.UserAuthorized = GetWorkItemField(objWorkItem, CoreField.AuthorizedAs); objTask.BoardColumn = GetWorkItemField(objWorkItem, CoreField.BoardColumn); objTask.BoardColumnDone = GetWorkItemField(objWorkItem, CoreField.BoardColumnDone); objTask.BoardLane = GetWorkItemField(objWorkItem, CoreField.BoardLane); objTask.LinkType = GetWorkItemField(objWorkItem, CoreField.LinkType); objTask.NodeName = objWorkItem.NodeName; // GetWorkItemField(objWorkItem, CoreField.NodeName); objTask.Reason = objWorkItem.Reason; // GetWorkItemField(objWorkItem, CoreField.Reason); objTask.RelatedLinkCount = GetWorkItemField(objWorkItem, CoreField.RelatedLinkCount).GetInt(0); // Añade la tarea a la colección objColTasks.Add(objTask); for (int intIndex = 0; intIndex < objWorkItem.Links.Count; intIndex++) { RelatedLink objLink = objWorkItem.Links[intIndex] as RelatedLink; if (objLink != null) { System.Diagnostics.Debug.WriteLine(objWorkItem.Id + " - " + objLink.ArtifactLinkType.Name + " -- " + objLink.RelatedWorkItemId + " - " + objLink.LinkTypeEnd.Name); } } } } // Devuelve la colección return(objColTasks); }
/// <summary> /// Carga la lista de tareas /// </summary> internal void LoadTasks(TaskModelCollection objColTasks) { // Inicializa la lista InitControl(); // Carga la lista foreach (TaskModel objTask in objColTasks) { ListViewItem lsiItem = lswTasks.AddRecord(objTask.ID.ToString(), objTask.Name); // Añade los elementos lsiItem.SubItems.Add(objTask.Type); lsiItem.SubItems.Add(objTask.AssignedTo); lsiItem.SubItems.Add(FormatHelper.Format(objTask.DateNew)); lsiItem.SubItems.Add(FormatHelper.Format(objTask.DateUpdate)); lsiItem.SubItems.Add(FormatHelper.Format(objTask.DateAuthorized)); lsiItem.SubItems.Add(objTask.NodeName); lsiItem.SubItems.Add(objTask.LinkType); lsiItem.SubItems.Add(objTask.RelatedLinkCount.ToString()); lsiItem.SubItems.Add(objTask.BoardColumn); lsiItem.SubItems.Add(objTask.BoardLane); lsiItem.SubItems.Add(objTask.BoardColumnDone); } }