/// <summary> /// Get the aggregated value of a custom column over all children for this task as it is displayed in the Hansoft client. /// </summary> /// <param name="columnName">The name of the column to get the value for</param> /// <returns>The requested value wrapped by a subclass of CustomColumnValue</returns> public CustomColumnValue GetAggregatedCustomColumnValue(string columnName) { HPMProjectCustomColumnsColumn customColumn = ProjectView.GetCustomColumn(columnName); if (customColumn != null) { return(GetAggregatedCustomColumnValue(customColumn)); } else { return(CustomColumnValue.FromInternalValue(this, null, "")); } }
/// <summary> /// Sets the value of a custom column for this task. /// </summary> /// <param name="customColumn">The custom column to set the value for.</param> /// <param name="value">The value to be set, can either be an instance of CustomColumnValue or any other type that can reasonably be converted /// to the end user consumable string representation of the value, i.e., as it is displayed in the Hansoft client.</param> public void SetCustomColumnValue(HPMProjectCustomColumnsColumn customColumn, object value) { if (value != null) { if (value is CustomColumnValue) { SetCustomColumnValueInternal(customColumn, ((CustomColumnValue)value).InternalValue); } else // TODO: Not right to set US culture here, it will for example screw up DateTime values { SetCustomColumnValue(customColumn, CustomColumnValue.FromEndUserString(this, customColumn, Convert.ToString(value, new System.Globalization.CultureInfo("en-US")))); } } else { SetCustomColumnValueInternal(customColumn, string.Empty); } }
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> /// Get the value of a custom column for this task. /// </summary> /// <param name="customColumn">The custom column to get the value for.</param> /// <returns>The requested value wrapped by a subclass of CustomColumnValue</returns> public CustomColumnValue GetCustomColumnValue(HPMProjectCustomColumnsColumn customColumn) { string cDataString = Session.TaskGetCustomColumnData(UniqueTaskID, customColumn.m_Hash); return(CustomColumnValue.FromInternalValue(this, customColumn, cDataString)); }
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); } } } } } }
/// <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()); }