Aspose.Tasks.Examples.CSharp.WorkingWithTasks.WorkingWithTaskConstraints.SetConstraintMustStartOn.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // Create project instance
            Project project1 = new Project(dataDir + "ConstraintMustStartOn.mpp");

            // ExStart:SetConstraintMustStartOn
            // Set constraint Must Start On for task with Id 5
            Task roof = project1.RootTask.Children.GetById(5);
            roof.Set(Tsk.ConstraintType, ConstraintType.MustStartOn);
            roof.Set(Tsk.ConstraintDate, new DateTime(2017, 1, 1, 9, 0, 0));
                        
            // Save project as pdf
            SaveOptions options = new PdfSaveOptions();
            options.StartDate = project1.Get(Prj.StartDate);
            options.Timescale = Timescale.ThirdsOfMonths;
            project1.Save(dataDir + "project_MustStartOn_out.pdf", options);
            // ExEnd:SetConstraintMustStartOn
        }
    }
SetConstraintMustStartOn