/// <summary> /// 创建任务模板 /// <remarks> /// 添加非标准任务,包括摘要任务、里程碑任务。 /// </remarks> /// </summary> /// <param name="subject">主题</param> /// <param name="start">开始偏移量</param> /// <param name="end">结束偏移量</param> /// <param name="isSummary">是否摘要任务</param> /// <returns>任务模板</returns> public static TaskTemp CreateTaskTemp(string subject, TimeSpan start, TimeSpan end, bool isSummary) { var taskTemp = new TaskTemp { Subject = subject, Start = start, End = end, IsSummary = isSummary }; taskTemp.GenerateNewIdentity(); taskTemp.IsMileStone = start == end; return taskTemp; }
/// <summary> /// 设置父项 /// </summary> /// <param name="taskTemp">父项</param> private void SetParent(TaskTemp taskTemp) { if (taskTemp == null || taskTemp.IsTransient()) { throw new ArgumentException("任务模板父项参数为空!"); } Parent = taskTemp; ParentId = taskTemp.Id; }
/// <summary> /// 添加子项 /// </summary> /// <param name="taskTemp">子项</param> /// <returns>添加的子项</returns> public TaskTemp AddChild(TaskTemp taskTemp) { if (taskTemp == null || taskTemp.IsTransient()) { throw new ArgumentException("任务模板子项参数为空!"); } Children.Add(taskTemp); taskTemp.SetParent(this); return taskTemp; }