public static string AggregatedStatus(Task feature)
 {
     var status = CalcAggregatedStatus(LinkedTasks(feature));
     var signoff = feature.GetCustomColumnValue(SIGNOFF);
     if (signoff == null)
         return status;
     if (status == "Completed")
         return signoff.ToString() == ACCEPTED ? status : "In progress";
     return status;
 }
Exemplo n.º 2
0
        private void DoUpdate()
        {
            List <Task> targetItems = targetProjectView.Find(targetFind);
            List <Task> sourceItems = sourceProjectView.Find(targetFind);

            foreach (Hansoft.ObjectWrapper.Task targetTask in targetItems)
            {
                Hansoft.ObjectWrapper.Task sourceTask = sourceItems.FirstOrDefault(s => s.LinkedTasks.Contains(targetTask));
                if (sourceTask != null)
                {
                    foreach (ColumnMapping mapping in columnMappings)
                    {
                        // TODO: Simplify the sequence below
                        if (mapping.SourceColumn.IsCustomColumn && mapping.TargetColumn.IsCustomColumn && (mapping.SourceColumn.CustomColumn.m_Type == mapping.TargetColumn.CustomColumn.m_Type))
                        {
                            targetTask.SetCustomColumnValue(mapping.TargetColumn.CustomColumn, CustomColumnValue.FromInternalValue(targetTask, mapping.TargetColumn.CustomColumn, sourceTask.GetCustomColumnValue(mapping.SourceColumn.CustomColumn).InternalValue));
                        }
                        else
                        {
                            object sourceValue;
                            if (mapping.SourceColumn.IsCustomColumn)
                            {
                                sourceValue = sourceTask.GetCustomColumnValue(mapping.SourceColumn.CustomColumn);
                            }
                            else
                            {
                                sourceValue = sourceTask.GetDefaultColumnValue(mapping.SourceColumn.DefaultColumnType);
                            }
                            if (mapping.TargetColumn.IsCustomColumn)
                            {
                                string endUserString;
                                if (sourceValue is float || sourceValue is double)
                                {
                                    endUserString = String.Format(new System.Globalization.CultureInfo("en-US"), "{0:F1}", sourceValue);
                                }
                                else
                                {
                                    endUserString = sourceValue.ToString();
                                }
                                targetTask.SetCustomColumnValue(mapping.TargetColumn.CustomColumn, endUserString);
                            }
                            else
                            {
                                targetTask.SetDefaultColumnValue(mapping.TargetColumn.DefaultColumnType, sourceValue);
                            }
                        }
                    }
                }
            }
        }
 private EHPMTaskWallItemColor? GetColor(Task task)
 {
     var type = task.GetCustomColumnValue("Type");
     if (type == null)
         return null;
     var color = TypeColorConfig.GetTypeColor(type.ToString());
     if (color == null)
         return EHPMTaskWallItemColor.Orange;
     switch (color)
     {
         case "Yellow":
             return EHPMTaskWallItemColor.Yellow;
         case "Blue":
             return EHPMTaskWallItemColor.Blue;
         case "Green":
             return EHPMTaskWallItemColor.Green;
         case "Red":
             return EHPMTaskWallItemColor.Red;
         case "Magenta":
             return EHPMTaskWallItemColor.Magenta;
         case "Orange":
             return EHPMTaskWallItemColor.Orange;
     }
     return null;
 }
        public static string FeatureSummary(Task feature)
        {
            IEnumerable<Task> allTasks;
            try
            {
                allTasks = LinkedTasks(feature);
            }
            catch (UnlinkedException)
            {
                if (feature.GetCustomColumnValue("Planned sprint").ToString() != string.Empty)
                    feature.SetCustomColumnValue("Planned sprint", string.Empty);
                return string.Empty;
            }
            var projects = allTasks.Select(t => t.Project.Name).Distinct();
            var allPlannedSprints = new SortedSet<string>();
            var plannedIPSprint = false;

            var summary_builder = new StringBuilder();
            summary_builder.Append(string.Format(FEATURE_SUMMARY_LINE_FORMAT, FEATURE_SUMMARY_HEADINGS));
            summary_builder.Append(FEATURE_SUMMARY_HEADER_SEPARATOR);

            foreach (var project in projects)
            {
                var team = project.Substring(TEAM_PROJECT_PREFIX.Length);
                var teamShort = team.Substring(0, (team.Length > 14) ? 13 : team.Length) + ((team.Length > 14) ? "…" : "");
                var tasks = allTasks.Where(t => t.Project.Name == project);
                var status = CalcAggregatedStatus(tasks);
                var completedPoints = tasks.Where(t => LeafCompleted(t)).Sum(t => t.Points);
                var totalPoints = tasks.Sum(t => t.Points);
                var completedStories = tasks.Where(t => LeafCompleted(t)).Count();
                var totalStories = tasks.Count();
                var plannedSprints = tasks
                    .Where(t => !LeafCompleted(t))
                    .Select(t => t.GetCustomColumnValue("Planned sprint"))
                    .Where(sprintColumn => sprintColumn != null)
                    .Select(sprintColumn => sprintColumn.ToString())
                    .Where(sprint => sprint.Length != 0)
                    .Distinct()
                    .OrderBy(sprint => sprint);
                var plannedSprintsString = plannedSprints.Aggregate(
                        new StringBuilder(),
                        (sb, sprint) => sb.Append(sprint).Append(", "),
                        sb => sb.Length > 0 ? sb.ToString(0, sb.Length-2) : "");
                var productOwner = ProductOwnerConfig.GetProductOwner(team, "unknown");
                var productOwnerShort = productOwner.Substring(0, (productOwner.Length > 14) ? 13 : productOwner.Length) + ((productOwner.Length > 14) ? "…" : "");

                summary_builder.AppendFormat(FEATURE_SUMMARY_LINE_FORMAT,
                    teamShort, status, completedPoints + "/" + totalPoints, completedStories + "/" + totalStories, productOwnerShort, plannedSprintsString);

                if (plannedSprintsString.Length > 0)
                {
                    if (!plannedIPSprint && plannedSprints.Where(t => t == "IP").Any())
                        plannedIPSprint = true;
                    var maxPlannedSprint = plannedSprints.Where(t => t.StartsWith("S")).Max();
                    allPlannedSprints.Add(maxPlannedSprint);
                }
            }

            if (plannedIPSprint)
                feature.SetCustomColumnValue("Planned sprint", "IP");
            else if (allPlannedSprints.Count() > 0)
                feature.SetCustomColumnValue("Planned sprint", allPlannedSprints.Max());

            return summary_builder.ToString();
        }
 public static bool IsCompleted(Task feature)
 {
     var tasks = LinkedTasks(feature);
     if (tasks.Count() == 0)
         return false;
     var completed = tasks.All(i => (EHPMTaskStatus)i.AggregatedStatus.Value == EHPMTaskStatus.Completed);
     var signoffValue = feature.GetCustomColumnValue(SIGNOFF);
     if (signoffValue == null)
         return completed;
     var signoff = signoffValue.ToString() == ACCEPTED;
     return completed && signoff;
 }
 private void DoUpdateFromHistory(Task task, HPMDataHistory history)
 {
     // Ensure that we get the custom column of the right project
     HPMProjectCustomColumnsColumn actualCustomColumn = task.ProjectView.GetCustomColumn(trackingColumn.m_Name);
     DateTimeValue storedValue = (DateTimeValue)task.GetCustomColumnValue(actualCustomColumn);
     // ToInt64 will return the value as microseconds since 1970 Jan 1
     ulong storedHpmTime = storedValue.ToHpmDateTime();
     if (history.m_Latests.m_Time > storedHpmTime)
     {
         foreach (HPMDataHistoryEntry entry in history.m_HistoryEntries)
         {
             // Check if it is the status field
             if (entry.m_FieldID == 15)
             {
                 if (entry.m_Time > storedHpmTime)
                 {
                     storedHpmTime = entry.m_Time;
                     task.SetCustomColumnValue(trackingColumn, DateTimeValue.FromHpmDateTime(task, actualCustomColumn, storedHpmTime));
                 }
             }
         }
     }
 }
            internal void DoUpdate(Task task)
            {
                try
                {
                    Debug.Print("DeriveBehaviour - {0} - {1} - processing task \"{2}\"",
                        isCustomColumn ? customColumnName : defaultColumnType.ToString(),
                        expression,
                        task.Name);
                    var expressionValue = mInfo.Invoke(null, new object[] { task });
                    if (isCustomColumn)
                    {
                        // Ensure that we get the custom column of the right project
                        var customColumn = task.ProjectView.GetCustomColumn(customColumnName);
                        var oldValue = task.GetCustomColumnValue(customColumnName);

                        if (customColumn != null && oldValue != null && !oldValue.Equals(expressionValue))
                            task.SetCustomColumnValue(customColumn, expressionValue);
                    }
                    else
                    {
                        var oldValue = task.GetDefaultColumnValue(defaultColumnType);
                        if (oldValue != null && !oldValue.Equals(expressionValue))
                            task.SetDefaultColumnValue(defaultColumnType, expressionValue);
                    }
                }
                catch (TargetInvocationException e)
                {
                    // Hack to let column handlers bail out when they don't have any new value to set.
                    if (!(e.InnerException is NoNewValueException))
                        throw;
                }
            }
        public void addTask(Task task)
        {
            CustomColumnValue val = task.GetCustomColumnValue("Planned sprint");
            if (val != null && !String.IsNullOrEmpty(val.ToString()))
            {
                plannedSprints.Add(val.ToString());
            }

            if (task.DeepLeaves.Count > 0)
            {
                foreach (Task child in task.DeepLeaves)
                {
                    updateFromTask(child);
                }
            }
            else
            {
                updateFromTask(task);
            }
        }
        /// <summary>
        /// Creates the ProgramFeatureSummary and updates the points value based on the linked values.
        /// </summary>
        /// <param name="current_task"></param>
        /// <param name="updateTaskStatus">If set to true the points for the master item will be update with the aggregated points from the linked items.</param>
        /// <returns>A ASCI art table with containing a summary of what needs to be done.</returns>
        public static string ProgramFeatureSummary(Task current_task, bool updateTaskStatus)
        {
            Dictionary<string, TeamCollection> teamCollection = new Dictionary<string, TeamCollection>();
            Dictionary<string, TaskCollection> taskGroup = new Dictionary<string, TaskCollection>();
            taskGroup.Add("In progress", new TaskCollection("In progress", 0, 0));
            taskGroup.Add("Completed", new TaskCollection("Completed", 0, 0));
            taskGroup.Add("Blocked", new TaskCollection("Blocked", 0, 0));
            taskGroup.Add("Not done", new TaskCollection("Not done", 0, 0));
            taskGroup.Add("To be deleted", new TaskCollection("To be deleted", 0, 0));
            StringBuilder sb = new StringBuilder();
            foreach (Task task in current_task.LinkedTasks)
            {
                string team = task.Project.Name;
                if (team.ToLower().StartsWith("team - "))
                {
                    if (!teamCollection.ContainsKey(team))
                    {
                        TeamCollection collection = new TeamCollection(taskGroup);
                        collection.team = team;
                        teamCollection.Add(team, collection);
                    }
                    teamCollection[team].addTask(task);
                }
            }

            if (teamCollection.Count > 0)
            {
                string format = "<CODE>{0,-20} │ {1,-11} │ {2, -6} │ {3, -8}│ {4, -15}</CODE>";
                sb.Append(string.Format(format, new object[] { "Name", "Status", "Points", "Stories", "Planned sprint" }));
                sb.Append("\n<CODE>─────────────────────┼─────────────┼────────┼─────────┼───────────────────</CODE>\n");
                foreach (KeyValuePair<string, TeamCollection> pair in teamCollection)
                {
                    sb.Append(pair.Value.FormatString(format) + "\n");
                }

                if (hasParentHeader(current_task.Parent, "Development"))
                {
                    foreach (KeyValuePair<string, TaskCollection> taskPair in taskGroup)
                    {
                        createNewTask(current_task, taskPair.Value);
                    }
                }

                try
                {
                    CustomColumnValue v = current_task.GetCustomColumnValue("Team");
                    // Intead of creating the list I jut simply get the existing list and clear it
                    IList selectedTeams = v.ToStringList();
                    selectedTeams.Clear();
                    foreach (KeyValuePair<string, TeamCollection> pair in teamCollection)
                    {
                        string name = pair.Key.Substring(7);
                        if (!selectedTeams.Contains(name))
                        {
                            selectedTeams.Add(name);
                        }
                    }
                    CustomColumnValue.FromStringList(current_task, current_task.ProjectView.GetCustomColumn("Team"), selectedTeams);
                    CustomColumnValue newValue = CustomColumnValue.FromStringList(current_task, current_task.ProjectView.GetCustomColumn("Team"), selectedTeams);
                    current_task.SetCustomColumnValue("Team", newValue);
                }
                catch (Exception)
                {

                }
            }

            return sb.ToString();
        }