- The version of Aspose.Task is 23.4.
- Exporting using the following code can display relevant information such as completion percentage and work hours normally.
- However, adjusting the duration of any task will cause the duration of all tasks in the entire plan to change.
Please help investigate the specific reason.
public Dictionary<string, int> dicResource { get; set; } = new Dictionary<string, int>();
public int TaskIndex { get; set; }
[Test]
public void SaveProjectOverviewReport()
{
List<string> ids = new List<string>();
//StringBuilder strB = new StringBuilder();
//for (int i = 0; i < 1000000; i++)
//{
// string id = Guid.NewGuid().ToString();
// ids.Add(id);
// //strB.Append(id);
//}
//Stopwatch sw = new Stopwatch();
//sw.Start();
//List<string> aaa = ids.FindAll(p => p.Contains("abc"));
//Console.WriteLine($" List Contains 查询结果数量:{aaa.Count},耗时:{sw.Elapsed.TotalMilliseconds}ms");
//sw.Restart();
//List<string> bbb = ids.FindAll(p => p.IndexOf("abc") >= 0);
//Console.WriteLine($" IndexOf 查询结果数量:{bbb.Count},耗时:{sw.Elapsed.TotalMilliseconds}ms");
//sw.Restart();
//List<string> ccc = ids.FindAll(p => p.StartsWith("abc"));
//Console.WriteLine($" StartsWith 查询结果数量:{ccc.Count},耗时:{sw.Elapsed.TotalMilliseconds}ms");
///////////
////string str = strB.ToString();
////sw.Restart();
////List<string> ddd = str.IndexOf("abc") >= 0;
////Console.WriteLine($" IndexOf 查询结果数量:{bbb.Count},耗时:{sw.Elapsed.TotalMilliseconds}ms");
//Console.ReadLine();
//return;
//var project = new Project(@"C:\Users\A4\Desktop\Aspose测试\项目日历导出测试-2016版.mpp");
var project = new Project();
project.CalculationMode = CalculationMode.None;
project.WorkFormat = TimeUnitType.Day;
project.NewTasksAreManual = false;//新任务模式
project.StartDate = new DateTime(2022, 5, 27);
project.MinutesPerDay = 480;
project.Set(Prj.WorkFormat, TimeUnitType.Hour);
//设置日历
var calendar = project.Calendar;
calendar.WeekDays.Clear();
calendar.Exceptions.Clear();
//Calendar.MakeStandardCalendar(calendar);
calendar.Name = "默认日历";
var sunday = new WeekDay(DayType.Sunday);
sunday.DayWorking = false;
calendar.WeekDays.Add(sunday);
var monday = new WeekDay(DayType.Monday);
//WeekDay.SetDefaultWorkingTime(monday);
monday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 8, 0, 0), new DateTime(2023, 1, 1, 12, 0, 0)));
monday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 13, 0, 0), new DateTime(2023, 1, 1, 17, 0, 0)));
calendar.WeekDays.Add(monday);
var tuesday = new WeekDay(DayType.Tuesday);
//WeekDay.SetDefaultWorkingTime(tuesday);
tuesday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 8, 0, 0), new DateTime(2023, 1, 1, 12, 0, 0)));
tuesday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 13, 0, 0), new DateTime(2023, 1, 1, 17, 0, 0)));
calendar.WeekDays.Add(tuesday);
var wednesday = new WeekDay(DayType.Wednesday);
//WeekDay.SetDefaultWorkingTime(wednesday);
wednesday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 8, 0, 0), new DateTime(2023, 1, 1, 12, 0, 0)));
wednesday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 13, 0, 0), new DateTime(2023, 1, 1, 17, 0, 0)));
calendar.WeekDays.Add(wednesday);
var thursday = new WeekDay(DayType.Thursday);
//WeekDay.SetDefaultWorkingTime(thursday);
thursday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 8, 0, 0), new DateTime(2023, 1, 1, 12, 0, 0)));
thursday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 13, 0, 0), new DateTime(2023, 1, 1, 17, 0, 0)));
calendar.WeekDays.Add(thursday);
var friday = new WeekDay(DayType.Friday);
//WeekDay.SetDefaultWorkingTime(friday);
friday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 8, 0, 0), new DateTime(2023, 1, 1, 12, 0, 0)));
friday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 13, 0, 0), new DateTime(2023, 1, 1, 17, 0, 0)));
calendar.WeekDays.Add(friday);
var saturday = new WeekDay(DayType.Saturday);
saturday.DayWorking = false;
calendar.WeekDays.Add(saturday);
//特殊日历
//var calendar = project.Calendars.Add("Calendar1");
var exception = new CalendarException();
//exception.Name = "New Calendar Exception";
exception.EnteredByOccurrences = false;
exception.FromDate = new DateTime(2022, 1, 31, 0, 0, 0);
exception.ToDate = new DateTime(2022, 2, 6, 23, 59, 59);
exception.Type = CalendarExceptionType.Daily;
//exception.Month = Month.December;
exception.DayWorking = false;
calendar.Exceptions.Add(exception);
var exception2 = new CalendarException();
//exception2.Name = "New Calendar Exception";
exception2.EnteredByOccurrences = false;
exception2.FromDate = new DateTime(2021, 12, 31, 0, 0, 0);
exception2.ToDate = new DateTime(2022, 1, 2, 23, 59, 59);
exception2.Type = CalendarExceptionType.Daily;
//exception2.Month = Month.December;
exception2.DayWorking = false;
calendar.Exceptions.Add(exception2);
//project.CalculationMode = CalculationMode.Automatic;
//project.Save(OutDir + "我的测试计划" + DateTime.Now.ToString("MMddHHmmss") + ".mpp");
//return;
//设置资源日历
//foreach (var item in dicResource)
//{
// Calendar cale = project.Calendars.Add(item.Key);
// cale.Uid = item.Value;
// cale.Name = item.Key;
// //cale.BaseCalendar = project.Calendars.GetByUid(1);
//}
#region 设置项目资源
dicResource["xucan"] = 1;
dicResource["yangjunling"] = 2;
dicResource["yaoyuan.yd"] = 3;
dicResource["chenbo"] = 4;
dicResource["fuhongcai"] = 5;
dicResource["wanglingna"] = 6;
dicResource["zhangfeng"] = 7;
dicResource["liuqianlong"] = 8;
dicResource["hyq.hyq"] = 9;
dicResource["huangfei"] = 10;
dicResource["liuqi"] = 11;
dicResource["lijun"] = 12;
dicResource["wangwu"] = 13;
dicResource["wangzhao"] = 14;
dicResource["zhangzhenxing"] = 15;
dicResource["shuyuehong"] = 16;
dicResource["lisi"] = 17;
dicResource["zhuchuanli"] = 18;
dicResource["liukun"] = 19;
dicResource["liufeng"] = 20;
dicResource["zhangsan"] = 21;
dicResource["tangxiaofeng"] = 22;
foreach (var item in dicResource)
{
project.Resources.Add(item.Key);
}
#endregion
//任务
Task task = project.RootTask.Children.Add("我的测试计划");
task.Id = 1;
task.IgnoreResourceCalendar = true;
task.OutlineLevel = 1;
task.Duration = project.GetDuration(68, TimeUnitType.Day);
task.Start = new DateTime(2022, 5, 27);
task.Finish = new DateTime(2022, 8, 30); ;
task.PercentComplete = 11;
task.IsMilestone = false;
//task.ConstraintType =
//task.ConstraintDate =
task.IsEstimated = true;//是否估计
task.IsManual = false;
project.ResourceAssignments.Add(task, project.Resources.GetById(dicResource["xucan"]));
//Task task1 = task.Children.Add("Task1");
TaskIndex = 2;
Task Task1 = TaskInit(project, parentTask: task, "Task1", durationDays: 3, new DateTime(2022, 5, 27), new DateTime(2022, 5, 31), 100, isMileStone: true, new string[1] { "xucan" });
Task Task11 = TaskInit(project, parentTask: Task1, "Task11", durationDays: 3, new DateTime(2022, 5, 27), new DateTime(2022, 5, 31), 100, isMileStone: false, new string[1] { "yangjunling" });
Task Task111 = TaskInit(project, parentTask: Task11, "Task111", durationDays: 3, new DateTime(2022, 5, 27), new DateTime(2022, 5, 31), 100, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 05, 27, 08, 0, 0));
Task Task112 = TaskInit(project, parentTask: Task11, "Task112", durationDays: 3, new DateTime(2022, 5, 27), new DateTime(2022, 5, 31), 100, isMileStone: false, new string[1] { "yaoyuan.yd" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 05, 27, 08, 0, 0));
Task Task2 = TaskInit(project, parentTask: task, "Task2", durationDays: 6, new DateTime(2022, 6, 1), new DateTime(2022, 6, 8), 100, isMileStone: true, new string[1] { "xucan" }, Task1);
Task Task21 = TaskInit(project, parentTask: Task2, "Task21", durationDays: 3, new DateTime(2022, 6, 1), new DateTime(2022, 6, 3), 100, isMileStone: false, new string[1] { "chenbo" });
Task Task22 = TaskInit(project, parentTask: Task2, "Task22", durationDays: 3, new DateTime(2022, 6, 1), new DateTime(2022, 6, 3), 100, isMileStone: false, new string[1] { "xucan" });
Task Task221 = TaskInit(project, parentTask: Task2, "Task221", durationDays: 3, new DateTime(2022, 6, 1), new DateTime(2022, 6, 3), 100, isMileStone: false, new string[1] { "xucan" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 1, 12, 9, 0, 0));
Task Task23 = TaskInit(project, parentTask: Task2, "Task23", durationDays: 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 100, isMileStone: false, new string[1] { "xucan" }, Task22);
Task Task3 = TaskInit(project, parentTask: task, "Task3", durationDays: 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 25, isMileStone: true, new string[1] { "yaoyuan.yd" }, Task22);
Task Task31 = TaskInit(project, parentTask: Task3, "Task31", durationDays: 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 0, isMileStone: false, new string[1] { "chenbo" });
Task Task311 = TaskInit(project, parentTask: Task31, "Task311", durationDays: 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 0, isMileStone: false, new string[1] { "chenbo" });
Task Task312 = TaskInit(project, parentTask: Task31, "Task312", durationDays: 0, new DateTime(2022, 6, 6), new DateTime(2022, 6, 6), 0, isMileStone: true, new string[1] { "fuhongcai" });
//以下自动生成
Task Task32 = TaskInit(project, parentTask: Task3, "Task32", durationDays: 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 0, isMileStone: false, new string[1] { "yaoyuan.yd" }, null);
Task Task33 = TaskInit(project, parentTask: Task3, "Task33", durationDays: 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 0, isMileStone: false, new string[1] { "wanglingna" }, null);
Task Task331 = TaskInit(project, parentTask: Task33, "Task331", durationDays: 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 0, isMileStone: false, new string[1] { "wanglingna" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 04, 15, 09, 00, 0));
Task Task34 = TaskInit(project, parentTask: Task3, "Task34", durationDays: 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 100, isMileStone: false, new string[1] { "xucan" }, null);
Task Task4 = TaskInit(project, parentTask: task, "Task4", durationDays: 3, new DateTime(2022, 6, 8), new DateTime(2022, 6, 13), 0, isMileStone: true, new string[1] { "xucan" }, Task3);
Task Task41 = TaskInit(project, parentTask: Task4, "Task41", durationDays: 3, new DateTime(2022, 6, 9), new DateTime(2022, 6, 13), 0, isMileStone: false, new string[1] { "wanglingna" }, null);
Task Task42 = TaskInit(project, parentTask: Task4, "Task42", durationDays: 3, new DateTime(2022, 6, 9), new DateTime(2022, 6, 13), 0, isMileStone: false, new string[1] { "zhangfeng" }, null);
Task Task43 = TaskInit(project, parentTask: Task4, "Task43", durationDays: 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, isMileStone: true, new string[1] { "liuqianlong" }, null);
Task Task44 = TaskInit(project, parentTask: Task4, "Task44", durationDays: 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, isMileStone: true, new string[1] { "fuhongcai" }, null);
Task Task45 = TaskInit(project, parentTask: Task4, "Task45", durationDays: 3, new DateTime(2022, 6, 9), new DateTime(2022, 6, 13), 0, isMileStone: false, new string[1] { "hyq.hyq" }, null);
Task Task46 = TaskInit(project, parentTask: Task4, "Task46", durationDays: 2, new DateTime(2022, 6, 9), new DateTime(2022, 6, 10), 0, isMileStone: false, new string[1] { "huangfei" }, null);
Task Task47 = TaskInit(project, parentTask: Task4, "Task47", durationDays: 3, new DateTime(2022, 6, 9), new DateTime(2022, 6, 13), 0, isMileStone: false, new string[1] { "hyq.hyq" }, null);
Task Task48 = TaskInit(project, parentTask: Task4, "Task48", durationDays: 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, isMileStone: true, new string[1] { "huangfei" }, null);
Task Task49 = TaskInit(project, parentTask: Task4, "Task49", durationDays: 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, isMileStone: true, new string[1] { "yaoyuan.yd" }, null);
Task Task410 = TaskInit(project, parentTask: Task4, "Task410", durationDays: 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, isMileStone: true, new string[1] { "hyq.hyq" }, null);
Task Task4101 = TaskInit(project, parentTask: Task410, "Task4101", durationDays: 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, isMileStone: true, new string[1] { "hyq.hyq" }, null);
Task Task4102 = TaskInit(project, parentTask: Task410, "Task4102", durationDays: 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, isMileStone: true, new string[1] { "wanglingna" }, Task4101);
Task Task411 = TaskInit(project, parentTask: Task41, "Task411", durationDays: 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, isMileStone: true, new string[1] { "xucan" }, null);
Task Task5 = TaskInit(project, parentTask: task, "Task5", durationDays: 55, new DateTime(2022, 6, 14), new DateTime(2022, 8, 29), 11, isMileStone: true, new string[1] { "xucan" }, Task4);
Task Task51 = TaskInit(project, parentTask: Task5, "Task51", durationDays: 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, isMileStone: false, new string[1] { "xucan" }, null);
Task Task511 = TaskInit(project, parentTask: Task51, "Task511", durationDays: 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, isMileStone: false, new string[1] { "wanglingna" }, null);
Task Task5111 = TaskInit(project, parentTask: Task511, "Task5111", durationDays: 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, isMileStone: false, new string[1] { "wanglingna" }, null);
Task Task5112 = TaskInit(project, parentTask: Task511, "Task5112", durationDays: 1, new DateTime(2022, 6, 14), new DateTime(2022, 6, 14), 0, isMileStone: false, new string[1] { "wanglingna" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 05, 27, 08, 00, 0));
Task Task52 = TaskInit(project, parentTask: Task5, "Task52", durationDays: 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, isMileStone: false, new string[1] { "zhangfeng" }, null);
Task Task521 = TaskInit(project, parentTask: Task52, "Task521", durationDays: 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, isMileStone: false, new string[2] { "zhangfeng", "liuqi" }, null);
Task Task522 = TaskInit(project, parentTask: Task52, "Task522", durationDays: 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, isMileStone: false, new string[1] { "zhangfeng" }, null);
Task Task53 = TaskInit(project, parentTask: Task5, "Task53", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "liuqianlong" }, null);
Task Task531 = TaskInit(project, parentTask: Task53, "Task531", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "liuqianlong" }, null);
Task Task532 = TaskInit(project, parentTask: Task53, "Task532", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "liuqianlong" }, null);
Task Task5321 = TaskInit(project, parentTask: Task532, "Task5321", durationDays: 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, isMileStone: false, new string[1] { "lijun" }, null);
Task Task5322 = TaskInit(project, parentTask: Task532, "Task5322", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "liuqianlong" }, null);
Task Task5323 = TaskInit(project, parentTask: Task532, "Task5323", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "wangwu" }, null);
Task Task5324 = TaskInit(project, parentTask: Task532, "Task5324", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "wangwu" }, null);
Task Task54 = TaskInit(project, parentTask: Task5, "Task54", durationDays: 7, new DateTime(2022, 6, 14), new DateTime(2022, 6, 22), 100, isMileStone: false, new string[1] { "fuhongcai" }, null);
Task Task541 = TaskInit(project, parentTask: Task54, "Task541", durationDays: 7, new DateTime(2022, 6, 14), new DateTime(2022, 6, 22), 100, isMileStone: false, new string[1] { "fuhongcai" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 05, 27, 08, 00, 0));
Task Task542 = TaskInit(project, parentTask: Task54, "Task542", durationDays: 7, new DateTime(2022, 6, 14), new DateTime(2022, 6, 22), 100, isMileStone: false, new string[1] { "fuhongcai" }, null);
Task Task543 = TaskInit(project, parentTask: Task54, "Task543", durationDays: 7, new DateTime(2022, 6, 14), new DateTime(2022, 6, 22), 100, isMileStone: false, new string[1] { "fuhongcai" }, null);
Task Task55 = TaskInit(project, parentTask: Task5, "Task55", durationDays: 6, new DateTime(2022, 6, 14), new DateTime(2022, 6, 21), 0, isMileStone: false, new string[1] { "chenbo" }, null);
Task Task551 = TaskInit(project, parentTask: Task55, "Task551", durationDays: 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, isMileStone: false, new string[1] { "chenbo" }, null);
Task Task5511 = TaskInit(project, parentTask: Task551, "Task5511", durationDays: 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, isMileStone: false, new string[1] { "chenbo" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 09, 08, 00, 0));
Task Task5512 = TaskInit(project, parentTask: Task551, "Task5512", durationDays: 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, isMileStone: false, new string[1] { "wangzhao" }, null);
Task Task5513 = TaskInit(project, parentTask: Task551, "Task5513", durationDays: 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, isMileStone: false, new string[1] { "hyq.hyq" }, null);
Task Task5514 = TaskInit(project, parentTask: Task551, "Task5514", durationDays: 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, isMileStone: false, new string[1] { "huangfei" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 05, 19, 09, 00, 0));
Task Task552 = TaskInit(project, parentTask: Task55, "Task552", durationDays: 6, new DateTime(2022, 6, 14), new DateTime(2022, 6, 21), 0, isMileStone: false, new string[2] { "huangfei", "hyq.hyq" }, null);
Task Task56 = TaskInit(project, parentTask: Task5, "Task56", durationDays: 55, new DateTime(2022, 6, 14), new DateTime(2022, 8, 29), 0, isMileStone: false, new string[1] { "yaoyuan.yd" }, null);
Task Task561 = TaskInit(project, parentTask: Task56, "Task561", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "yaoyuan.yd" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 01, 08, 00, 0));
Task Task562 = TaskInit(project, parentTask: Task56, "Task562", durationDays: 5, new DateTime(2022, 6, 21), new DateTime(2022, 6, 27), 0, isMileStone: false, new string[1] { "yaoyuan.yd" }, Task531);
Task Task563 = TaskInit(project, parentTask: Task56, "Task563", durationDays: 30, new DateTime(2022, 6, 28), new DateTime(2022, 8, 8), 0, isMileStone: false, new string[1] { "yaoyuan.yd" }, Task562);
Task Task564 = TaskInit(project, parentTask: Task56, "Task564", durationDays: 15, new DateTime(2022, 8, 9), new DateTime(2022, 8, 29), 0, isMileStone: false, new string[1] { "yaoyuan.yd" }, Task563);
Task Task57 = TaskInit(project, parentTask: Task5, "Task57", durationDays: 15, new DateTime(2022, 6, 14), new DateTime(2022, 7, 4), 0, isMileStone: false, new string[1] { "xucan" }, null);
Task Task571 = TaskInit(project, parentTask: Task57, "Task571", durationDays: 15, new DateTime(2022, 6, 14), new DateTime(2022, 7, 4), 0, isMileStone: false, new string[1] { "zhangzhenxing" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task572 = TaskInit(project, parentTask: Task57, "Task572", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "shuyuehong" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task573 = TaskInit(project, parentTask: Task57, "Task573", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "shuyuehong" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task574 = TaskInit(project, parentTask: Task57, "Task574", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "liuqianlong" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task575 = TaskInit(project, parentTask: Task57, "Task575", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "lisi" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task576 = TaskInit(project, parentTask: Task57, "Task576", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "lisi" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task577 = TaskInit(project, parentTask: Task57, "Task577", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "zhuchuanli" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task578 = TaskInit(project, parentTask: Task57, "Task578", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "lisi" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task58 = TaskInit(project, parentTask: Task5, "Task58", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "yangjunling" }, null);
Task Task581 = TaskInit(project, parentTask: Task58, "Task581", durationDays: 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task582 = TaskInit(project, parentTask: Task58, "Task582", durationDays: 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task583 = TaskInit(project, parentTask: Task58, "Task583", durationDays: 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, isMileStone: false, new string[1] { "chenbo" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task584 = TaskInit(project, parentTask: Task58, "Task584", durationDays: 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
Task Task59 = TaskInit(project, parentTask: Task5, "Task59", durationDays: 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, isMileStone: false, new string[1] { "xucan" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 14, 08, 00, 0));
Task Task6 = TaskInit(project, parentTask: task, "Task6", durationDays: 50, new DateTime(2022, 6, 22), new DateTime(2022, 8, 30), 0, isMileStone: true, new string[1] { "xucan" }, Task55);
Task Task61 = TaskInit(project, parentTask: Task6, "Task61", durationDays: 3, new DateTime(2022, 6, 22), new DateTime(2022, 6, 24), 0, isMileStone: false, new string[1] { "liukun" }, null);
Task Task611 = TaskInit(project, parentTask: Task61, "Task611", durationDays: 3, new DateTime(2022, 6, 22), new DateTime(2022, 6, 24), 0, isMileStone: false, new string[1] { "lisi" }, null);
Task Task612 = TaskInit(project, parentTask: Task61, "Task612", durationDays: 2, new DateTime(2022, 6, 22), new DateTime(2022, 6, 23), 0, isMileStone: false, new string[1] { "liufeng" }, null);
Task Task62 = TaskInit(project, parentTask: Task6, "Task62", durationDays: 17, new DateTime(2022, 6, 22), new DateTime(2022, 7, 14), 0, isMileStone: false, new string[1] { "liukun" }, null);
Task Task621 = TaskInit(project, parentTask: Task62, "Task621", durationDays: 5, new DateTime(2022, 6, 27), new DateTime(2022, 7, 1), 0, isMileStone: false, new string[1] { "liukun" }, Task611);
Task Task622 = TaskInit(project, parentTask: Task62, "Task622", durationDays: 4, new DateTime(2022, 7, 4), new DateTime(2022, 7, 7), 0, isMileStone: false, new string[1] { "lisi" }, Task621);
Task Task623 = TaskInit(project, parentTask: Task62, "Task623", durationDays: 3, new DateTime(2022, 6, 22), new DateTime(2022, 6, 24), 0, isMileStone: false, new string[1] { "lisi" }, null);
Task Task624 = TaskInit(project, parentTask: Task62, "Task624", durationDays: 4, new DateTime(2022, 6, 27), new DateTime(2022, 6, 30), 0, isMileStone: false, new string[1] { "liukun" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 27, 08, 00, 0));
Task Task625 = TaskInit(project, parentTask: Task62, "Task625", durationDays: 10, new DateTime(2022, 7, 1), new DateTime(2022, 7, 14), 0, isMileStone: false, new string[1] { "liukun" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 01, 08, 00, 0));
Task Task626 = TaskInit(project, parentTask: Task62, "Task626", durationDays: 4, new DateTime(2022, 7, 1), new DateTime(2022, 7, 6), 0, isMileStone: false, new string[1] { "zhangsan" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 01, 08, 00, 0));
Task Task627 = TaskInit(project, parentTask: Task62, "Task627", durationDays: 5, new DateTime(2022, 6, 27), new DateTime(2022, 7, 1), 0, isMileStone: false, new string[1] { "zhangfeng" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 27, 08, 00, 0));
Task Task628 = TaskInit(project, parentTask: Task62, "Task628", durationDays: 5, new DateTime(2022, 6, 27), new DateTime(2022, 7, 1), 0, isMileStone: false, new string[1] { "lisi" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 27, 08, 00, 0));
Task Task629 = TaskInit(project, parentTask: Task62, "Task629", durationDays: 5, new DateTime(2022, 6, 27), new DateTime(2022, 7, 1), 0, isMileStone: false, new string[1] { "lisi" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 27, 08, 00, 0));
Task Task63 = TaskInit(project, parentTask: Task6, "Task63", durationDays: 16, new DateTime(2022, 7, 15), new DateTime(2022, 8, 5), 0, isMileStone: false, new string[1] { "liukun" }, null);
Task Task631 = TaskInit(project, parentTask: Task63, "Task631", durationDays: 16, new DateTime(2022, 7, 15), new DateTime(2022, 8, 5), 0, isMileStone: false, new string[1] { "liukun" }, Task625);
Task Task632 = TaskInit(project, parentTask: Task63, "Task632", durationDays: 10, new DateTime(2022, 7, 15), new DateTime(2022, 7, 28), 0, isMileStone: false, new string[1] { "chenbo" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 15, 08, 00, 0));
Task Task633 = TaskInit(project, parentTask: Task63, "Task633", durationDays: 10, new DateTime(2022, 7, 15), new DateTime(2022, 7, 28), 0, isMileStone: false, new string[1] { "tangxiaofeng" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 15, 08, 00, 0));
Task Task634 = TaskInit(project, parentTask: Task63, "Task634", durationDays: 5, new DateTime(2022, 7, 25), new DateTime(2022, 7, 29), 0, isMileStone: false, new string[1] { "liukun" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 25, 08, 00, 0));
Task Task635 = TaskInit(project, parentTask: Task63, "Task635", durationDays: 5, new DateTime(2022, 7, 25), new DateTime(2022, 7, 29), 0, isMileStone: false, new string[1] { "zhangfeng" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 25, 08, 00, 0));
Task Task64 = TaskInit(project, parentTask: Task6, "Task64", durationDays: 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, isMileStone: false, new string[1] { "yangjunling" }, null);
Task Task641 = TaskInit(project, parentTask: Task64, "Task641", durationDays: 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
Task Task642 = TaskInit(project, parentTask: Task64, "Task642", durationDays: 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
Task Task643 = TaskInit(project, parentTask: Task64, "Task643", durationDays: 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
Task Task644 = TaskInit(project, parentTask: Task64, "Task644", durationDays: 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
Task Task645 = TaskInit(project, parentTask: Task64, "Task645", durationDays: 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
Task Task646 = TaskInit(project, parentTask: Task64, "Task646", durationDays: 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
Task Task647 = TaskInit(project, parentTask: Task64, "Task647", durationDays: 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, isMileStone: false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
Task Task65 = TaskInit(project, parentTask: Task6, "Task65", durationDays: 5, new DateTime(2022, 7, 25), new DateTime(2022, 7, 29), 0, isMileStone: false, new string[1] { "yaoyuan.yd" }, null);
Task Task651 = TaskInit(project, parentTask: Task65, "Task651", durationDays: 5, new DateTime(2022, 7, 25), new DateTime(2022, 7, 29), 0, isMileStone: false, new string[1] { "yaoyuan.yd" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 25, 08, 00, 0));
Task Task66 = TaskInit(project, parentTask: Task6, "Task66", durationDays: 4, new DateTime(2022, 8, 25), new DateTime(2022, 8, 30), 0, isMileStone: false, new string[1] { "liukun" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 25, 08, 00, 0));
// one can save the overview report to PDF file to the specified path
project.Save(OutDir + "我的测试计划" + DateTime.Now.ToString("MMddHHmmss") + ".mpp");
// ExEnd:SaveProjectOverviewReport
}
private Task TaskInit(Project project, Task parentTask, string currentTaskName, int durationDays,
DateTime start, DateTime finish, int persent, bool isMileStone, string[] resources,
Task beforeTask = null, ConstraintType limitType = ConstraintType.AsSoonAsPossible, DateTime? limitDateTime = null)
{
int outLineLevel = currentTaskName.Replace("task", "").Replace("Task", "").Length + 1;
if (currentTaskName.EndsWith("10"))
{
outLineLevel--;
}
Task task = parentTask.Children.Add(currentTaskName);
task.Id = TaskIndex;
task.IgnoreResourceCalendar = true;
task.OutlineLevel = outLineLevel;
task.Duration = project.GetDuration(durationDays, TimeUnitType.Day);
task.Start = start;// new DateTime(2022, 6, 1);
task.Finish = finish;// new DateTime(2022, 6, 8);
task.PercentComplete = persent;// 100;
task.IsMilestone = isMileStone;
task.IsEstimated = true;//是否估计
task.IsManual = false;
task.ConstraintType = limitType;
if (limitDateTime.HasValue)
{
task.ConstraintDate = limitDateTime.Value;
}
foreach (var item in resources)
{
var resAss = project.ResourceAssignments.Add(task, project.Resources.GetById(dicResource[item]));
}
if (beforeTask != null)
{
project.TaskLinks.Add(beforeTask, task, TaskLinkType.FinishToStart, project.GetWork(0));
}
task.ActualWork = project.GetWork(durationDays * project.MinutesPerDay * persent * 8D / (project.MinutesPerDay * 100D));
task.RemainingWork = project.GetWork(durationDays * project.MinutesPerDay * (100 - persent) * 8D / (project.MinutesPerDay * 100D));
task.Work = project.GetWork(durationDays * project.MinutesPerDay * 8D / project.MinutesPerDay * 1D);
TaskIndex++;
return task;
}
img_v2_77749042-7dbc-449d-8f68-c5ba06edee6g.jpg (248.9 KB)
img_v2_6830d724-de94-4e19-a240-3b56c354f26g.jpg (208.9 KB)