Modifying the duration of tasks in the exported MPP file may cause all content to be changed when opened in Microsoft Project

  1. The version of Aspose.Task is 23.4.
  2. Exporting using the following code can display relevant information such as completion percentage and work hours normally.
  3. 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)

@Jiangqiming,
we need some time to examine the sample code.

OK, Waitting for u online :face_with_monocle:

@Jiangqiming,
the investigation is still in progress, we will inform when it is completed.

Hi
New issue,
If the generated task has a child task, and the completion percentage of the child task is 100, the completion percentage of the parent task should also be 100, but it is not now, it is now 99

@Jiangqiming,
thank you for the info. Will check this also.

@Jiangqiming,
could you check this thread.
The main reason is that you use CalculationMode.None.
In this mode you should set all related task and assignments fields by yourself because all auto calculations are turned off.

The current situation is that after setting CalculationMode.None, the exported data is displayed correctly. However, changing the content will cause the entire plan to change, as shown in the screenshot. I want to confirm what attributes need to be assigned values when setting CalculationMode.None to enable the exported data to be modified without causing incorrect changes.

In addition, if I set it to CalculationMode.None first, complete the data assembly, and then set it to CalculationMode.Automatic, will this situation not occur? However, this scenario seems to have been tested and still doesn’t work.

Could you please advise what attributes need to be assigned values when setting CalculationMode.None to enable the exported data to be modified without causing incorrect changes? Thank you.

When CalculationMode.None changed to CalculationMode.Automatic, the fields are not recalculated.
You will need to call project.Recalculate also.

hi,
Have you tried this code I posted? I feel that I still can’t generate the correct mpp file. Also, I’m using version 23.6 now

@Jiangqiming,

The main issue is that you create tasks with automatic scheduling mode (IsManual == false)
by using the following line in your code:
project.NewTasksAreManual = false;

Microsoft Project discovers that some resources are overallocated and reschedules such a tasks to another dates.

You could start by creating tasks with manual scheduling mode.

I think it may not be just a problem with the scheduling mode, because I have tried three modes, and set it manually first, then set it to automatic and recalculate after the creation is complete, even if this is the case, the correct mpp file cannot be exported.
A few of the more obvious issues:

  1. The duration of the exported summary tasks is all 0
  2. When the task is set to start no earlier than the xxxx date, the planned start time of the task may also be modified to the xxxx date.

These problems can be reproduced in the code I posted before, please try it.

@Jiangqiming,
could you try the following fixed code? I tried and looks like it produces the correct mpp.

The fixes are the following:

  1. use CalculationMode.Automatic, thus allowing Outline level, Ids, Timephased data, etc to be calculated automatically.
  2. Use tasks with IsManual = false.
  3. TaskInit was modified to set correct start \ finish dates.
    For example, new DateTime(2022, 5, 27) is a midnight, a non working time according to project’s calendar.
    The correct usage is new DateTime(2022, 5, 27, 8, 0, 0).
        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>();

            var project = new Project();
            project.CalculationMode = CalculationMode.Automatic;
            project.WorkFormat = TimeUnitType.Day;
            project.NewTasksAreManual = true;//新任务模式

            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)));
            monday.DayWorking = true;
            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)));
            tuesday.DayWorking = true;
            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)));
            wednesday.DayWorking = true;
            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)));
            thursday.DayWorking = true;
            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)));
            friday.DayWorking = true;
            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.Save(OutDir + "我的测试计划" + DateTime.Now.ToString("MMddHHmmss") + ".mpp");

            //return;


            #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.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, task, "Task1", 3, new DateTime(2022, 5, 27), new DateTime(2022, 5, 31), 100, true, new string[1] { "xucan" });
            Task Task11 = TaskInit(project, Task1, "Task11", 3, new DateTime(2022, 5, 27), new DateTime(2022, 5, 31), 100, false, new string[1] { "yangjunling" });
            Task Task111 = TaskInit(project, Task11, "Task111", 3, new DateTime(2022, 05, 27), new DateTime(2022, 5, 31), 100, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 05, 27, 08, 0, 0));
            Task Task112 = TaskInit(project, Task11, "Task112", 3, new DateTime(2022, 05, 27), new DateTime(2022, 5, 31), 100, false, new string[1] { "yaoyuan.yd" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 05, 27, 08, 0, 0));

            Task Task2 = TaskInit(project, task, "Task2", 6, new DateTime(2022, 6, 1), new DateTime(2022, 6, 8), 100, true, new string[1] { "xucan" }, Task1);
            Task Task21 = TaskInit(project, Task2, "Task21", 3, new DateTime(2022, 6, 1), new DateTime(2022, 6, 3), 100, false, new string[1] { "chenbo" });
            Task Task22 = TaskInit(project, Task2, "Task22", 3, new DateTime(2022, 6, 1), new DateTime(2022, 6, 3), 100, false, new string[1] { "xucan" });
            Task Task221 = TaskInit(project, Task2, "Task221", 3, new DateTime(2022, 6, 1), new DateTime(2022, 6, 3), 100, false, new string[1] { "xucan" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 1, 12, 9, 0, 0));
            Task Task23 = TaskInit(project, Task2, "Task23", 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 100, false, new string[1] { "xucan" }, Task22);

            Task Task3 = TaskInit(project, task, "Task3", 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 25, true, new string[1] { "yaoyuan.yd" }, Task22);
            Task Task31 = TaskInit(project, Task3, "Task31", 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 0, false, new string[1] { "chenbo" });
            Task Task311 = TaskInit(project, Task31, "Task311", 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 0, false, new string[1] { "chenbo" });
            Task Task312 = TaskInit(project, Task31, "Task312", 0, new DateTime(2022, 6, 6), new DateTime(2022, 6, 6), 0, true, new string[1] { "fuhongcai" });

            //以下自动生成
            Task Task32 = TaskInit(project, Task3, "Task32", 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 0, false, new string[1] { "yaoyuan.yd" }, null);
            Task Task33 = TaskInit(project, Task3, "Task33", 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 0, false, new string[0], null);
            Task Task331 = TaskInit(project, Task33, "Task331", 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 0, false, new string[1] { "wanglingna" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 04, 15, 09, 00, 0));
            Task Task34 = TaskInit(project, Task3, "Task34", 3, new DateTime(2022, 6, 6), new DateTime(2022, 6, 8), 100, false, new string[1] { "xucan" }, null);
            Task Task4 = TaskInit(project, task, "Task4", 3, new DateTime(2022, 6, 8), new DateTime(2022, 6, 13), 0, true, new string[1] { "xucan" }, Task3);
            Task Task41 = TaskInit(project, Task4, "Task41", 3, new DateTime(2022, 6, 9), new DateTime(2022, 6, 13), 0, false, new string[1] { "wanglingna" }, null);
            Task Task42 = TaskInit(project, Task4, "Task42", 3, new DateTime(2022, 6, 9), new DateTime(2022, 6, 13), 0, false, new string[1] { "zhangfeng" }, null);
            Task Task43 = TaskInit(project, Task4, "Task43", 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, true, new string[1] { "liuqianlong" }, null);
            Task Task44 = TaskInit(project, Task4, "Task44", 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, true, new string[1] { "fuhongcai" }, null);
            Task Task45 = TaskInit(project, Task4, "Task45", 3, new DateTime(2022, 6, 9), new DateTime(2022, 6, 13), 0, false, new string[1] { "hyq.hyq" }, null);
            Task Task46 = TaskInit(project, Task4, "Task46", 2, new DateTime(2022, 6, 9), new DateTime(2022, 6, 10), 0, false, new string[1] { "huangfei" }, null);
            Task Task47 = TaskInit(project, Task4, "Task47", 3, new DateTime(2022, 6, 9), new DateTime(2022, 6, 13), 0, false, new string[1] { "hyq.hyq" }, null);
            Task Task48 = TaskInit(project, Task4, "Task48", 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, true, new string[1] { "huangfei" }, null);
            Task Task49 = TaskInit(project, Task4, "Task49", 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, true, new string[1] { "yaoyuan.yd" }, null);
            Task Task410 = TaskInit(project, Task4, "Task410", 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, true, new string[1] { "hyq.hyq" }, null);
            Task Task4101 = TaskInit(project, Task410, "Task4101", 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, true, new string[1] { "hyq.hyq" }, null);
            Task Task4102 = TaskInit(project, Task410, "Task4102", 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, true, new string[1] { "wanglingna" }, Task4101);
            Task Task411 = TaskInit(project, Task41, "Task411", 0, new DateTime(2022, 6, 8), new DateTime(2022, 6, 8), 0, true, new string[1] { "xucan" }, null);
            Task Task5 = TaskInit(project, task, "Task5", 55, new DateTime(2022, 6, 14), new DateTime(2022, 8, 29), 11, true, new string[1] { "xucan" }, Task4);
            Task Task51 = TaskInit(project, Task5, "Task51", 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, false, new string[1] { "xucan" }, null);
            Task Task511 = TaskInit(project, Task51, "Task511", 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, false, new string[1] { "wanglingna" }, null);
            Task Task5111 = TaskInit(project, Task511, "Task5111", 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, false, new string[1] { "wanglingna" }, null);
            Task Task5112 = TaskInit(project, Task511, "Task5112", 1, new DateTime(2022, 6, 14), new DateTime(2022, 6, 14), 0, false, new string[1] { "wanglingna" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 05, 27, 08, 00, 0));
            Task Task52 = TaskInit(project, Task5, "Task52", 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, false, new string[1] { "zhangfeng" }, null);
            Task Task521 = TaskInit(project, Task52, "Task521", 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, false, new string[2] { "zhangfeng", "liuqi" }, null);
            Task Task522 = TaskInit(project, Task52, "Task522", 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, false, new string[1] { "zhangfeng" }, null);
            Task Task53 = TaskInit(project, Task5, "Task53", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "liuqianlong" }, null);
            Task Task531 = TaskInit(project, Task53, "Task531", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "liuqianlong" }, null);
            Task Task532 = TaskInit(project, Task53, "Task532", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "liuqianlong" }, null);
            Task Task5321 = TaskInit(project, Task532, "Task5321", 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, false, new string[1] { "lijun" }, null);
            Task Task5322 = TaskInit(project, Task532, "Task5322", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "liuqianlong" }, null);
            Task Task5323 = TaskInit(project, Task532, "Task5323", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "wangwu" }, null);
            Task Task5324 = TaskInit(project, Task532, "Task5324", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "wangwu" }, null);
            Task Task54 = TaskInit(project, Task5, "Task54", 7, new DateTime(2022, 6, 14), new DateTime(2022, 6, 22), 100, false, new string[1] { "fuhongcai" }, null);
            Task Task541 = TaskInit(project, Task54, "Task541", 7, new DateTime(2022, 6, 14), new DateTime(2022, 6, 22), 100, false, new string[1] { "fuhongcai" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 05, 27, 08, 00, 0));
            Task Task542 = TaskInit(project, Task54, "Task542", 7, new DateTime(2022, 6, 14), new DateTime(2022, 6, 22), 100, false, new string[1] { "fuhongcai" }, null);
            Task Task543 = TaskInit(project, Task54, "Task543", 7, new DateTime(2022, 6, 14), new DateTime(2022, 6, 22), 100, false, new string[1] { "fuhongcai" }, null);
            Task Task55 = TaskInit(project, Task5, "Task55", 6, new DateTime(2022, 6, 14), new DateTime(2022, 6, 21), 0, false, new string[1] { "chenbo" }, null);
            Task Task551 = TaskInit(project, Task55, "Task551", 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, false, new string[1] { "chenbo" }, null);
            Task Task5511 = TaskInit(project, Task551, "Task5511", 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, false, new string[1] { "chenbo" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 09, 08, 00, 0));
            Task Task5512 = TaskInit(project, Task551, "Task5512", 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, false, new string[1] { "wangzhao" }, null);
            Task Task5513 = TaskInit(project, Task551, "Task5513", 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, false, new string[1] { "hyq.hyq" }, null);
            Task Task5514 = TaskInit(project, Task551, "Task5514", 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, false, new string[1] { "huangfei" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 05, 19, 09, 00, 0));
            Task Task552 = TaskInit(project, Task55, "Task552", 6, new DateTime(2022, 6, 14), new DateTime(2022, 6, 21), 0, false, new string[2] { "huangfei", "hyq.hyq" }, null);
            Task Task56 = TaskInit(project, Task5, "Task56", 55, new DateTime(2022, 6, 14), new DateTime(2022, 8, 29), 0, false, new string[1] { "yaoyuan.yd" }, null);
            Task Task561 = TaskInit(project, Task56, "Task561", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "yaoyuan.yd" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 01, 08, 00, 0));
            Task Task562 = TaskInit(project, Task56, "Task562", 5, new DateTime(2022, 6, 21), new DateTime(2022, 6, 27), 0, false, new string[1] { "yaoyuan.yd" }, Task531);
            Task Task563 = TaskInit(project, Task56, "Task563", 30, new DateTime(2022, 6, 28), new DateTime(2022, 8, 8), 0, false, new string[1] { "yaoyuan.yd" }, Task562);
            Task Task564 = TaskInit(project, Task56, "Task564", 15, new DateTime(2022, 8, 9), new DateTime(2022, 8, 29), 0, false, new string[1] { "yaoyuan.yd" }, Task563);
            Task Task57 = TaskInit(project, Task5, "Task57", 15, new DateTime(2022, 6, 14), new DateTime(2022, 7, 4), 0, false, new string[1] { "xucan" }, null);
            Task Task571 = TaskInit(project, Task57, "Task571", 15, new DateTime(2022, 6, 14), new DateTime(2022, 7, 4), 0, false, new string[1] { "zhangzhenxing" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task572 = TaskInit(project, Task57, "Task572", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "shuyuehong" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task573 = TaskInit(project, Task57, "Task573", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "shuyuehong" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task574 = TaskInit(project, Task57, "Task574", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "liuqianlong" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task575 = TaskInit(project, Task57, "Task575", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "lisi" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task576 = TaskInit(project, Task57, "Task576", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "lisi" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task577 = TaskInit(project, Task57, "Task577", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "zhuchuanli" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task578 = TaskInit(project, Task57, "Task578", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "lisi" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task58 = TaskInit(project, Task5, "Task58", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "yangjunling" }, null);
            Task Task581 = TaskInit(project, Task58, "Task581", 5, new DateTime(2022, 6, 14), new DateTime(2022, 6, 20), 0, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task582 = TaskInit(project, Task58, "Task582", 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task583 = TaskInit(project, Task58, "Task583", 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, false, new string[1] { "chenbo" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task584 = TaskInit(project, Task58, "Task584", 3, new DateTime(2022, 6, 14), new DateTime(2022, 6, 16), 0, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 06, 08, 00, 0));
            Task Task59 = TaskInit(project, Task5, "Task59", 2, new DateTime(2022, 6, 14), new DateTime(2022, 6, 15), 0, false, new string[1] { "xucan" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 14, 08, 00, 0));
            Task Task6 = TaskInit(project, task, "Task6", 50, new DateTime(2022, 6, 22), new DateTime(2022, 8, 30), 0, true, new string[1] { "xucan" }, Task55);
            Task Task61 = TaskInit(project, Task6, "Task61", 3, new DateTime(2022, 6, 22), new DateTime(2022, 6, 24), 0, false, new string[1] { "liukun" }, null);
            Task Task611 = TaskInit(project, Task61, "Task611", 3, new DateTime(2022, 6, 22), new DateTime(2022, 6, 24), 0, false, new string[1] { "lisi" }, null);
            Task Task612 = TaskInit(project, Task61, "Task612", 2, new DateTime(2022, 6, 22), new DateTime(2022, 6, 23), 0, false, new string[1] { "liufeng" }, null);
            Task Task62 = TaskInit(project, Task6, "Task62", 17, new DateTime(2022, 6, 22), new DateTime(2022, 7, 14), 0, false, new string[1] { "liukun" }, null);
            Task Task621 = TaskInit(project, Task62, "Task621", 5, new DateTime(2022, 6, 27), new DateTime(2022, 7, 1), 0, false, new string[1] { "liukun" }, Task611);
            Task Task622 = TaskInit(project, Task62, "Task622", 4, new DateTime(2022, 7, 4), new DateTime(2022, 7, 7), 0, false, new string[1] { "lisi" }, Task621);
            Task Task623 = TaskInit(project, Task62, "Task623", 3, new DateTime(2022, 6, 22), new DateTime(2022, 6, 24), 0, false, new string[1] { "lisi" }, null);
            Task Task624 = TaskInit(project, Task62, "Task624", 4, new DateTime(2022, 6, 27), new DateTime(2022, 6, 30), 0, false, new string[1] { "liukun" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 27, 08, 00, 0));
            Task Task625 = TaskInit(project, Task62, "Task625", 10, new DateTime(2022, 7, 1), new DateTime(2022, 7, 14), 0, false, new string[1] { "liukun" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 01, 08, 00, 0));
            Task Task626 = TaskInit(project, Task62, "Task626", 4, new DateTime(2022, 7, 1), new DateTime(2022, 7, 6), 0, false, new string[1] { "zhangsan" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 01, 08, 00, 0));
            Task Task627 = TaskInit(project, Task62, "Task627", 5, new DateTime(2022, 6, 27), new DateTime(2022, 7, 1), 0, false, new string[1] { "zhangfeng" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 27, 08, 00, 0));
            Task Task628 = TaskInit(project, Task62, "Task628", 5, new DateTime(2022, 6, 27), new DateTime(2022, 7, 1), 0, false, new string[1] { "lisi" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 27, 08, 00, 0));
            Task Task629 = TaskInit(project, Task62, "Task629", 5, new DateTime(2022, 6, 27), new DateTime(2022, 7, 1), 0, false, new string[1] { "lisi" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 06, 27, 08, 00, 0));
            Task Task63 = TaskInit(project, Task6, "Task63", 16, new DateTime(2022, 7, 15), new DateTime(2022, 8, 5), 0, false, new string[1] { "liukun" }, null);
            Task Task631 = TaskInit(project, Task63, "Task631", 16, new DateTime(2022, 7, 15), new DateTime(2022, 8, 5), 0, false, new string[1] { "liukun" }, Task625);
            Task Task632 = TaskInit(project, Task63, "Task632", 10, new DateTime(2022, 7, 15), new DateTime(2022, 7, 28), 0, false, new string[1] { "chenbo" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 15, 08, 00, 0));
            Task Task633 = TaskInit(project, Task63, "Task633", 10, new DateTime(2022, 7, 15), new DateTime(2022, 7, 28), 0, false, new string[1] { "tangxiaofeng" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 15, 08, 00, 0));
            Task Task634 = TaskInit(project, Task63, "Task634", 5, new DateTime(2022, 7, 25), new DateTime(2022, 7, 29), 0, false, new string[1] { "liukun" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 25, 08, 00, 0));
            Task Task635 = TaskInit(project, Task63, "Task635", 5, new DateTime(2022, 7, 25), new DateTime(2022, 7, 29), 0, false, new string[1] { "zhangfeng" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 25, 08, 00, 0));
            Task Task64 = TaskInit(project, Task6, "Task64", 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, false, new string[1] { "yangjunling" }, null);
            Task Task641 = TaskInit(project, Task64, "Task641", 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
            Task Task642 = TaskInit(project, Task64, "Task642", 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
            Task Task643 = TaskInit(project, Task64, "Task643", 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
            Task Task644 = TaskInit(project, Task64, "Task644", 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
            Task Task645 = TaskInit(project, Task64, "Task645", 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
            Task Task646 = TaskInit(project, Task64, "Task646", 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
            Task Task647 = TaskInit(project, Task64, "Task647", 5, new DateTime(2022, 8, 1), new DateTime(2022, 8, 5), 0, false, new string[1] { "yangjunling" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 08, 01, 08, 00, 0));
            Task Task65 = TaskInit(project, Task6, "Task65", 5, new DateTime(2022, 7, 25), new DateTime(2022, 7, 29), 0, false, new string[1] { "yaoyuan.yd" }, null);
            Task Task651 = TaskInit(project, Task65, "Task651", 5, new DateTime(2022, 7, 25), new DateTime(2022, 7, 29), 0, false, new string[1] { "yaoyuan.yd" }, null, ConstraintType.StartNoEarlierThan, new DateTime(2022, 07, 25, 08, 00, 0));
            Task Task66 = TaskInit(project, Task6, "Task66", 4, new DateTime(2022, 8, 25), new DateTime(2022, 8, 30), 0, 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");

            //project.Recalculate();


            // 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)
        {
            Task task = parentTask.Children.Add(currentTaskName);
            task.IgnoreResourceCalendar = true;
            task.Duration = project.GetDuration(durationDays, TimeUnitType.Day);

            if (start.Hour == 0)
            {
                start = start.AddHours(8);
            }
            task.Start = start;
            
            if (finish.Hour == 0)
            {
                finish = finish.AddHours(17);
            }

            task.Finish = finish;
            task.PercentComplete = persent;// 100;
            task.IsMilestone = isMileStone;
            task.IsEstimated = false;//是否估计
            task.IsManual = true;
            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;
        }

Thx very much for u reply, Im trying this code……

Hello, after I executed this code, I can basically export the correct mpp file.
But I found another problem, please pay attention to it: after setting the automatic task export, the leaf task percentage under the summary task is 100%, but if you use project.RecalCulate(), the progress will be updated to 99%.

@Jiangqiming,
thank you for drawing our attention, we will investigate the issue.

@Jiangqiming,
looks like we need more details.
We added project.Recalculate() before saving the project to file and cannot observe the behavior you’ve described.

could you specify or attach a lines of code, please?

Could you provide the name or unique id of the task?

Where do you observe 99% ? When opening the resulting MPP file in MS Project or by using Aspose.Tasks and calling task.Get(Tsk.PercentComplete) ?