using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SunlightCentralizedControlManagement_SCCM_.UserClass { /// /// Passive data class holding schedule information /// [Serializable] public class IP_Task { /// /// Initialize a new task to hold schedule information /// public IP_Task() { Complete = 0.0f; Start = TimeSpan.Zero; End = new TimeSpan(1, 0, 0, 0); Duration = new TimeSpan(1, 0, 0, 0); Slack = TimeSpan.Zero; } /// /// Get or set the Name of this Task /// public string Name { get; set; } /// /// Indicate whether this task is collapsed such that sub tasks are hidden from view. Only groups can be collasped. /// public bool IsCollapsed { get; set; } /// /// Get or set the pecentage complete of this task, expressed in float between 0.0 and 1.0f. /// public float Complete { get; internal set; } /// /// Get the start time of this Task relative to the project start /// public TimeSpan Start { get; internal set; } /// /// Get the end time of this Task relative to the project start /// public TimeSpan End { get; internal set; } /// /// Get the duration of this Task in days /// public TimeSpan Duration { get; internal set; } /// /// Get the amount of slack (free float) /// public TimeSpan Slack { get; internal set; } /// /// Convert this Task to a descriptive string /// /// public override string ToString() { return string.Format("[Name = {0}, Start = {1}, End = {2}, Duration = {3}, Complete = {4}]", Name, Start, End, Duration, Complete); } } /// /// ProjectManager interface /// /// Task class type /// Resource class type public interface IProjectManager where T : IP_Task where R : class { /// /// Add task to project manager /// /// void Add(T task); /// /// Delete task from project manager /// /// void Delete(T task); /// /// Group the member task under the group task. Group task cannot have relations. /// /// /// void Group(T group, T member); /// /// Ungroup member task from group task. If there are no more task under group, group will become a normal task. /// /// /// void Ungroup(T group, T member); /// /// Split the specified task into consecutive parts part1 and part2. /// /// The regular task to split which has duration of at least 2 to make two parts of 1 time unit duration each. /// New Task part (1) of the split task, with the start time of the original task and the specified duration value. /// New Task part (2) of the split task, starting 1 time unit after part (1) ends and having the remaining of the duration of the origina task. /// The duration of part (1) will be set to the specified duration value but will also be adjusted to approperiate value if necessary. void Split(T task, T part1, T part2, TimeSpan duration); /// /// Split the specified part and obtain another part from it. /// /// The task part to split which has duration of at least 2 to make two parts of 1 time unit duration each. Its duration will be set to the specified duration value. /// New Task part of the original part, starting 1 time unit after it ends and having the remaining of the duration of the original part. /// The duration of part (1) will be set to the specified duration value but will also be adjusted to approperiate value if necessary. void Split(T part, T another, TimeSpan duration); /// /// Join part1 and part2 in a split task into a single part represented by part1, and part2 will be deleted from the ProjectManager. /// The resulting part will have a duration total of the two parts. Schedule of other parts will be packed according to direction of join. /// If the join will result in only one part remaining, the split task will merge instead. /// /// The part to keep in the ProjectManager after the join completes successfully. /// The part to join into part1 and be deleted afterwards from the ProjectManager. void Join(T part1, T part2); /// /// Merge all the parts of the splitted task back into one task, having duration equal to sum of total duration of individual task parts, and aggregating the resources onto the resulting task. /// /// The split Task to merge void Merge(T split); /// /// Get the parts of the split task /// /// /// IEnumerable PartsOf(T split); /// /// Get the split task that the specified part belogs to. /// /// /// T SplitTaskOf(T part); /// /// Get whether the specified task is a split task /// /// /// bool IsSplit(T task); /// /// Get whether the specified task is a part of a split task /// /// /// bool IsPart(T task); /// /// Ungroup all member task under the specfied group task. The specified group task will become a normal task. /// /// void Ungroup(T group); /// /// Move the specified task by offset positions in the task enumeration /// /// /// void Move(T task, int offset); /// /// Set a relation between the precedent and dependant task /// /// /// void Relate(T precedent, T dependant); /// /// Unset the relation between the precedent and dependant task, if any. /// /// /// void Unrelate(T precedent, T dependant); /// /// Remove all dependant task from specified precedent task /// /// void Unrelate(T precedent); /// /// Enumerate through all tasks that is a precedent, having dependants. /// IEnumerable Precedents { get; } /// /// Enumerate through all the tasks in the ProjectManager. /// If there are no change to groups and no add/delete tasks, the order between consecutive calls is preserved. /// IEnumerable Tasks { get; } /// /// Set the start time of the specified task. /// /// /// Number of timescale units after ProjectManager.Start void SetStart(T task, TimeSpan start); /// /// Set the end time of the specified task. Duration is automatically adjusted to satisfy. /// /// /// Number of timescale units after ProjectManager.Start void SetEnd(T task, TimeSpan end); /// /// Set the duration of the specified task from start to end. /// /// /// Number of timescale units between ProjectManager.Start void SetDuration(T task, TimeSpan duration); /// /// Set the percentage complete of the specified task from 0.0f to 1.0f. /// No effect on group tasks as they will get the aggregated percentage complete of all child tasks /// /// /// void SetComplete(T task, float complete); /// /// Set whether to collapse the specified group task. No effect on regular tasks. /// /// /// void SetCollapse(T group, bool collasped); /// /// Set the "now" time. Its value is the number of timescale units after the start time. /// TimeSpan Now { get; } /// /// Set the start date of the project. /// DateTime Start { get; set; } /// /// Get the zero-based index of the specified task /// /// /// int IndexOf(T task); /// /// Enumerate through parent group and grandparent groups of the specified task /// /// /// IEnumerable GroupsOf(T task); /// /// Enumerate through all the children and grandchildren of the specified group /// /// /// IEnumerable MembersOf(T group); /// /// Enumerate through all the direct children of the specified group /// /// /// IEnumerable DirectMembersOf(T group); /// /// Enumerate through all the direct precedents and indirect precedents of the specified task /// /// /// IEnumerable PrecedentsOf(T task); /// /// Enumerate through all the direct dependants and indirect dependants of the specified task /// /// /// IEnumerable DependantsOf(T task); /// /// Enumerate through all the direct precedents of the specified task /// /// /// IEnumerable DirectPrecedentsOf(T task); /// /// Enumerate through all the direct dependants of the specified task /// /// /// IEnumerable DirectDependantsOf(T task); /// /// Enumerate through all the critical paths. Each path is an enumerable of tasks, starting from the final task of each path. /// IEnumerable> CriticalPaths { get; } /// /// Get the parent group of the specified task /// /// /// T DirectGroupOf(T task); /// /// Get whether the specified task is a group /// /// /// bool IsGroup(T task); /// /// Get whether the specified task is a member /// /// /// bool IsMember(T task); /// /// Get whether the specified task has relations, either has dependants or has precedents connecting to it. /// /// /// bool HasRelations(T task); /// /// Assign the specified resource to the specified task /// /// /// void Assign(T task, R resource); /// /// Unassign the specified resource from the specfied task /// /// /// void Unassign(T task, R resource); /// /// Unassign all resources from the specified task /// /// void Unassign(T task); /// /// Unassign the specified resource from all tasks that has this resource assigned /// /// void Unassign(R resource); /// /// Enumerate through all the resources that has been assigned to some task. /// IEnumerable Resources { get; } /// /// Enumerate through all the resources that has been assigned to the specified task. /// /// /// IEnumerable ResourcesOf(T task); /// /// Enumerate through all the tasks that has the specified resource assigned to it. /// /// /// IEnumerable TasksOf(R resource); } }