private static HansoftEnumValue getAggregatedStatus(Task task) { HPMTaskSummary summaryStatus = SessionManager.Session.TaskRefGetSummary(task.Id); if (task.Status.Text == task.AggregatedStatus.Text) { return(task.Status); } string statusString = "Not Done"; switch (summaryStatus.m_TaskStatus) { case EHPMTaskStatus.Blocked: statusString = "Blocked"; break; case EHPMTaskStatus.Completed: statusString = "Completed"; break; case EHPMTaskStatus.Deleted: statusString = "Deleted"; break; case EHPMTaskStatus.InProgress: statusString = "In Progress"; break; case EHPMTaskStatus.NewVersionOfSDKRequired: statusString = "New Version Of SDK Required"; break; case EHPMTaskStatus.NoStatus: statusString = "No Status"; break; case EHPMTaskStatus.NotDone: statusString = "Not Done"; break; } return(HansoftEnumValue.FromString(task.ProjectID, EHPMProjectDefaultColumn.ItemStatus, statusString)); }
public static HansoftEnumValue CalculateNewStatus(Task task, HansoftEnumValue prevStatus, HansoftEnumValue newStatus) { HansoftEnumValue finalStatus = null; // If either prevStatus or newStatus is null, the result is "the other value" (which can be null) if (prevStatus == null) { finalStatus = newStatus; } else if (newStatus == null) { finalStatus = prevStatus; } else if (prevStatus.Text.Equals(newStatus.Text)) { finalStatus = prevStatus; } // If any story is Blocked the feature is Blocked else if (prevStatus.Text.Equals("Blocked") || newStatus.Text.Equals("Blocked")) { finalStatus = HansoftEnumValue.FromString(task.ProjectID, EHPMProjectDefaultColumn.ItemStatus, "Blocked"); } // For all other combinations the result is InProgress else { finalStatus = HansoftEnumValue.FromString(task.ProjectID, EHPMProjectDefaultColumn.ItemStatus, "In progress"); } return(finalStatus); }
public static Task createNewTask(Task parent, TaskCollection taskCollection) { Task newTask = null; foreach (Task subtask in parent.Leaves) { if (subtask.Name.Equals(taskCollection.status)) { newTask = subtask; } } if (newTask == null && taskCollection.taskHeaders.Count > 0) { SprintSearchCollection searchResult = findSprintTaskID(parent); newTask = CreateTask(parent, parent.Project.UniqueID, taskCollection.status, searchResult); if (newTask == null) { return(null); } } if (taskCollection.taskHeaders.Count > 0) { if (!newTask.GetCustomColumnValue("Item count").Equals(taskCollection.taskHeaders.Count.ToString())) { newTask.SetCustomColumnValue("Item count", taskCollection.taskHeaders.Count.ToString()); } if (parent.Points > 0) { parent.Points = 0; } if (newTask.Points != taskCollection.totalPoints) { newTask.Points = taskCollection.totalPoints; newTask.WorkRemaining = taskCollection.totalPoints - taskCollection.completedPoints; } if (!newTask.Status.Text.Equals(taskCollection.status)) { newTask.Status = HansoftEnumValue.FromString(parent.ProjectID, EHPMProjectDefaultColumn.ItemStatus, taskCollection.status); try { SessionManager.Session.TaskSetCompleted(newTask.UniqueTaskID, taskCollection.status.Equals("Completed"), true); } catch (Exception) { } } } else if (newTask != null) { try { SessionManager.Session.TaskDelete(newTask.UniqueTaskID); } catch (Exception) { } } return(newTask); }