public static void Run()
        {
            // ExStart:ReadTaskWBS
            // Read project
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Project project1 = new Project(dataDir + "TaskWBS.mpp");

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(project1.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk in collector.Tasks)
            {
                Console.WriteLine(tsk.Get(Tsk.WBS));
                Console.WriteLine(tsk.Get(Tsk.WBSLevel));
                
                // Set custom WBS
                tsk.Set(Tsk.WBS, "custom wbs" + tsk.Get(Tsk.WBS));
            }
            // ExEnd:ReadTaskWBS

            // Save project as PDF
            project1.Save(dataDir + "TaskWBS_out.pdf", SaveFileFormat.PDF);
        }
        [Test] // ExSkip
        public void WorkWithNot()
        {
            var project = new Project(DataDir + "Project2.mpp");

            // gather all project tasks
            var coll = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, coll, 0);

            // create a filter condition
            var filter = new NullCondition();

            // and reverse it by applying <see cref="Aspose.Tasks.Util.Not`1" /> condition
            var condition = new Not <Task>(filter);

            // apply the condition to the collected tasks
            List <Task> collection = Filter(coll.Tasks, condition);

            foreach (var task in collection)
            {
                Console.WriteLine("Name: " + task.Get(Tsk.Name));

                // work with other properties...
            }

            // ...
        }
        public static void Run()
        {
            //ExStart:ReadTaskWBS
            // Read project
            string  dataDir  = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Project project1 = new Project(dataDir + "TaskWBS.mpp");

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(project1.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk in collector.Tasks)
            {
                Console.WriteLine(tsk.Get(Tsk.WBS));
                Console.WriteLine(tsk.Get(Tsk.WBSLevel));

                // Set custom WBS
                tsk.Set(Tsk.WBS, "custom wbs" + tsk.Get(Tsk.WBS));
            }
            //ExEnd:ReadTaskWBS

            // Save project as PDF
            project1.Save(dataDir + "TaskWBS_out.pdf", SaveFileFormat.PDF);
        }
        public static void Run()
        {
            // ExStart:ReadStopResumeDates
            // Read project from file stream
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            FileStream fs = new FileStream(dataDir + "StopResumeDates.mpp", FileMode.Open);
            Project prj = new Project(fs);
            fs.Close();

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Check Stop and Resume dates for all tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                if (tsk1.Get(Tsk.Stop).ToShortDateString() == "1/1/2000")
                    Console.WriteLine("Stop: NA");
                else
                    Console.WriteLine("Stop: " + tsk1.Get(Tsk.Stop).ToShortDateString());

                if (tsk1.Get(Tsk.Resume).ToShortDateString() == "1/1/2000")
                    Console.WriteLine("Resume: NA");
                else
                    Console.WriteLine("Resume: " + tsk1.Get(Tsk.Resume).ToShortDateString());
            }
            // ExEnd:ReadStopResumeDates
        }
        [Test] // ExSkip
        public void WorkWithAndAllCondition()
        {
            var project = new Project(DataDir + "Project2.mpp");

            // gather all project tasks
            var coll = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, coll, 0);

            var conditions = new List <ICondition <Task> >
            {
                // create a filter condition that filters not null tasks
                new NotNullCondition(),

                // create a filter condition that filters summary tasks
                new SummaryCondition()
            };

            // and join them by applying <see cref="Aspose.Tasks.Util.AndAllCondition`1" /> condition
            var joinedCondition = new AndAllCondition <Task>(conditions);

            // apply the condition to the collected tasks
            List <Task> collection = Filter(coll.Tasks, joinedCondition);

            Console.WriteLine("Filtered tasks: ");
            foreach (var task in collection)
            {
                Console.WriteLine("  Name: " + task.Get(Tsk.Name));

                // work with other properties...
            }

            // ...
        }
        public void ReadWriteTaskProperties()
        {
            // ExStart:ReadWriteTaskProperties
            // ExFor: Task.Get(Aspose.Tasks.Key{System.String,Aspose.Tasks.TaskKey})
            // ExFor: Task.Get``1(Aspose.Tasks.Key{``0,Aspose.Tasks.TaskKey})
            // ExFor: Task.Set(Aspose.Tasks.Key{System.DateTime,Aspose.Tasks.TaskKey},System.DateTime)
            // ExFor: Task.Set``1(Aspose.Tasks.Key{``0,Aspose.Tasks.TaskKey},``0)
            // ExSummary: Shows how to get/set task properties.
            var project = new Project();

            // Add task and set task properties
            var task = project.RootTask.Children.Add();

            task.Set(Tsk.Name, "Task1");
            task.Set(Tsk.Start, new DateTime(2020, 3, 31, 8, 0, 0));
            task.Set(Tsk.Finish, new DateTime(2020, 3, 31, 17, 0, 0));

            var collector = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (var tsk in collector.Tasks)
            {
                Console.WriteLine("Task Id: {0}", tsk.Get(Tsk.Id));
                Console.WriteLine("Task Uid: {0}", tsk.Get(Tsk.Uid));
                Console.WriteLine("Task Name: {0}", tsk.Get(Tsk.Name));
                Console.WriteLine("Task Start: {0}", tsk.Get(Tsk.Start));
                Console.WriteLine("Task Finish: {0}", tsk.Get(Tsk.Finish));
            }

            // ExEnd:ReadWriteTaskProperties
        }
        public static void Run()
        {
            // ExStart:GetConstraints
            string  dataDir  = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Project project1 = new Project(dataDir + "Project2.mpp");

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(project1.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Aspose.Tasks.Task tsk1 in collector.Tasks)
            {
                if (tsk1.Get(Tsk.ConstraintDate).ToShortDateString() == "1/1/2000")
                {
                    Console.WriteLine("NA");
                }
                else
                {
                    Console.WriteLine(tsk1.Get(Tsk.ConstraintDate).ToShortDateString());
                }

                Console.WriteLine(tsk1.Get(Tsk.ConstraintType).ToString());
            }
            // ExEnd:GetConstraints
        }
        public static void Run()
        {
            // ExStart:ReadActualTaskProperties
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

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

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(project.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task task in collector.Tasks)
            {
                Console.WriteLine("Task Name : " + task.Get(Tsk.Name));
                Console.WriteLine("Actual Start: " + task.Get(Tsk.ActualStart).ToLongDateString());
                Console.WriteLine("Actual Finish: " + task.Get(Tsk.ActualFinish).ToLongDateString());
                Console.WriteLine("Actual Duration: " + task.Get(Tsk.ActualDuration).TimeSpan.Hours.ToString());
                Console.WriteLine("Actual Cost: " + task.Get(Tsk.ActualCost).ToString());
                Console.WriteLine("---------------------------------------------");
            }
            // ExEnd:ReadActualTaskProperties
        }
        public static void Run()
        {
            // ExStart:FindEstimatedMilestoneTasks
            // Read project from file stream
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            FileStream fs = new FileStream(dataDir + "EstimatedMilestoneTasks.mpp", FileMode.Open);
            Project prj = new Project(fs);
            fs.Close();

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                string strEst = (tsk1.Get(Tsk.IsEstimated)) ? "Estimated" : "Non-Estimated";
                string strMileStone = (tsk1.Get(Tsk.IsMilestone)) ? "Milestone" : "Non-Milestone";
                Console.WriteLine(tsk1.Get(Tsk.Name) + " : " + strEst);
                Console.WriteLine(tsk1.Get(Tsk.Name) + " : " + strMileStone);
            }
            // ExEnd:FindEstimatedMilestoneTasks
        }
        public static void Run()
        {
            // ExStart:ReadActualTaskProperties
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

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

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(project.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task task in collector.Tasks)
            {
                Console.WriteLine("Task Name : " + task.Get(Tsk.Name));
                Console.WriteLine("Actual Start: " + task.Get(Tsk.ActualStart).ToLongDateString());
                Console.WriteLine("Actual Finish: " + task.Get(Tsk.ActualFinish).ToLongDateString());
                Console.WriteLine("Actual Duration: " + task.Get(Tsk.ActualDuration).TimeSpan.Hours.ToString());
                Console.WriteLine("Actual Cost: " + task.Get(Tsk.ActualCost).ToString());
                Console.WriteLine("---------------------------------------------");
            }
            // ExEnd:ReadActualTaskProperties
        }
        public static void Run()
        {
            // ExStart:ReadTaskProperties
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // Create project instance
            Project prj = new Project(dataDir + "ReadTaskProperties.mpp");

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk in collector.Tasks)
            {
                Console.WriteLine("Task Id: {0}", tsk.Get(Tsk.Id));
                Console.WriteLine("Task Uid: {0}", tsk.Get(Tsk.Uid));
                Console.WriteLine("Task Name: {0}", tsk.Get(Tsk.Name));
                Console.WriteLine("Task Start: {0}", tsk.Get(Tsk.Start));
                Console.WriteLine("Task Finish: {0}", tsk.Get(Tsk.Finish));
            }
            // ExEnd:ReadTaskProperties
        }
        public static void Run()
        {
            //ExStart:ReadTaskProperties
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // Create project instance
            Project prj = new Project(dataDir + "ReadTaskProperties.mpp");

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk in collector.Tasks)
            {
                Console.WriteLine("Task Id: {0}", tsk.Get(Tsk.Id));
                Console.WriteLine("Task Uid: {0}", tsk.Get(Tsk.Uid));
                Console.WriteLine("Task Name: {0}", tsk.Get(Tsk.Name));
                Console.WriteLine("Task Start: {0}", tsk.Get(Tsk.Start));
                Console.WriteLine("Task Finish: {0}", tsk.Get(Tsk.Finish));
            }
            //ExEnd:ReadTaskProperties
        }
Exemple #13
0
        public static void Run()
        {
            // ExStart:FindCriticalEffortDrivenTasks
            // Read project from file stream
            string     dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            FileStream fs      = new FileStream(dataDir + "CriticalEffortDrivenTasks.mpp", FileMode.Open);
            Project    prj     = new Project(fs);

            fs.Close();

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                string strED   = tsk1.Get(Tsk.IsEffortDriven) ? "EffortDriven" : "Non-EffortDriven";
                string strCrit = tsk1.Get(Tsk.IsCritical) ? "Critical" : "Non-Critical";
                Console.WriteLine(tsk1.Get(Tsk.Name) + " : " + strED);
                Console.WriteLine(tsk1.Get(Tsk.Name) + " : " + strCrit);
            }
            // ExEnd:FindCriticalEffortDrivenTasks
        }
        [Test] // ExSkip
        public void SortTasksByName()
        {
            var project   = new Project(DataDir + "project-sort.mpp");
            var collector = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, collector, 0);
            List <Task> tasks = collector.Tasks;

            tasks.Sort(new TaskNameComparer());

            foreach (var task in tasks)
            {
                Console.WriteLine(task.ToString());
            }
        }
        public void ReadBudgetWorkAndCost()
        {
            // ExStart:ReadBudgetWorkAndCost
            // ExFor: Rsc.BudgetWork
            // ExFor: Rsc.BudgetCost
            // ExSummary: Shows how to read budget work/cost values of a resource.
            var project = new Project(DataDir + "BudgetWorkAndCost.mpp");

            // Display budget work and budget cost for project summary task
            Console.WriteLine("projSummary.BudgetWork = " + project.RootTask.Get(Tsk.BudgetWork));
            Console.WriteLine("projSummary.BudgetCost = " + project.RootTask.Get(Tsk.BudgetCost));

            // Display resource budget work
            var rsc = project.Resources.GetByUid(6);

            Console.WriteLine("Resource BudgetWork = " + rsc.Get(Rsc.BudgetWork));

            // Display resource budget cost
            rsc = project.Resources.GetByUid(7);
            Console.WriteLine("Resource BudgetCost = " + rsc.Get(Rsc.BudgetCost));

            var collector = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, collector, 0);
            foreach (var task in collector.Tasks)
            {
                // Display assignment budget work and budget cost
                foreach (var assignment in task.Assignments)
                {
                    var resource = assignment.Get(Asn.Resource);
                    if (resource == null)
                    {
                        continue;
                    }

                    if (resource.Get(Rsc.Type) == ResourceType.Work)
                    {
                        Console.WriteLine("Assignment BudgetWork = " + assignment.Get(Asn.BudgetWork));
                    }
                    else
                    {
                        Console.WriteLine("Assignment BudgetCost = " + assignment.Get(Asn.BudgetCost));
                    }
                }
            }

            // ExEnd:ReadBudgetWorkAndCost
        }
Exemple #16
0
        public static void Run()
        {
            // ExStart:SortTasksByName
            string              dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Project             project = new Project(dataDir + "project-sort.mpp");
            ChildTasksCollector coll    = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, coll, 0);
            List <Task> tasks = coll.Tasks;

            tasks.Sort(new TaskNameComparer());

            foreach (Task task in tasks)
            {
                Console.WriteLine(task);
            }
            // ExEnd:SortTasksByName
        }
        [Test] // ExSkip
        public void WorkWithFind()
        {
            var project = new Project(DataDir + "Project2.mpp");

            // builds new tree of tasks which satisfy the condition
            var task = TaskUtils.Filter(project.RootTask, new FindByName("Task8"));

            // gather tasks from a tree
            var coll = new ChildTasksCollector();

            TaskUtils.Apply(task, coll, 0);

            // iterate over plain list of tasks
            // which durations are greater or equal than 2 working days
            foreach (var collTask in coll.Tasks)
            {
                Console.WriteLine("Name: " + collTask.Get(Tsk.Name) + "Duration: " + collTask.Get(Tsk.Duration).TimeSpan);
            }
        }
        public static void Run()
        {
            // ExStart:ReadParentChildTasks
            // Create project instance
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Project project1 = new Project(dataDir + "ParentChildTasks.mpp");
            
            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(project1.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                Console.WriteLine(tsk1.Get(Tsk.Name));
            }
            // ExEnd:ReadParentChildTasks
        }
        public void WorkWithApply()
        {
            // ExStart
            // ExFor: Util.TaskUtils
            // ExFor: Util.TaskUtils.Apply(Aspose.Tasks.Task,Aspose.Tasks.Util.ITreeAlgorithm{Aspose.Tasks.Task},System.Int32)
            // ExSummary: Shows how to work with a tree algorithm.
            var project = new Project(DataDir + "Project2.mpp");

            // gather all project tasks
            var coll = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, coll, 0);

            // work with tasks as with a plain list
            foreach (var task in coll.Tasks)
            {
                Console.WriteLine("Task Name: " + task.Get(Tsk.Name));
            }
            // ExEnd
        }
        public static void Run()
        {
            // ExStart:ReadParentChildTasks
            // Create project instance
            string  dataDir  = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Project project1 = new Project(dataDir + "ParentChildTasks.mpp");

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(project1.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                Console.WriteLine(tsk1.Get(Tsk.Name));
            }
            // ExEnd:ReadParentChildTasks
        }
        public void PrintResourceAssignmentCommonInformation()
        {
            // ExStart:PrintAssignmentCommonInformation
            // ExFor: ResourceAssignment.ToString()
            // ExSummary: Shows how to print common assignment info.
            var project = new Project(DataDir + "BudgetWorkAndCost.mpp");

            var collector = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, collector, 0);
            foreach (var task in collector.Tasks)
            {
                // display task's assignments
                foreach (var assignment in task.Assignments)
                {
                    Console.WriteLine(assignment.ToString());
                }
            }

            // ExEnd:PrintAssignmentCommonInformation
        }
        public static void Run()
        {
            //ExStart:ReadStopResumeDates
            // Read project from file stream
            string     dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            FileStream fs      = new FileStream(dataDir + "StopResumeDates.mpp", FileMode.Open);
            Project    prj     = new Project(fs);

            fs.Close();

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Check Stop and Resume dates for all tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                if (tsk1.Get(Tsk.Stop).ToShortDateString() == "1/1/2000")
                {
                    Console.WriteLine("Stop: NA");
                }
                else
                {
                    Console.WriteLine("Stop: " + tsk1.Get(Tsk.Stop).ToShortDateString());
                }

                if (tsk1.Get(Tsk.Resume).ToShortDateString() == "1/1/2000")
                {
                    Console.WriteLine("Resume: NA");
                }
                else
                {
                    Console.WriteLine("Resume: " + tsk1.Get(Tsk.Resume).ToShortDateString());
                }
            }
            //ExEnd:ReadStopResumeDates
        }
        public void WorkWithChildTasksCollector()
        {
            // ExStart:ReadParentChildTasks
            // ExFor: ChildTasksCollector
            // ExFor: ChildTasksCollector.#ctor
            // ExFor: ChildTasksCollector.Tasks
            // ExFor: ChildTasksCollector.Alg(Task,Int32)
            // ExSummary: Shows how to iterate over all tasks in a project as a plain list.
            var project = new Project(DataDir + "ParentChildTasks.mpp");

            var collector = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (var task in collector.Tasks)
            {
                Console.WriteLine(task.Get(Tsk.Name));
            }

            // ExEnd:ReadParentChildTasks
        }
        public static void Run()
        {
            // ExStart:ReadTaskPriority
            // Read project from file stream
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            FileStream fs = new FileStream(dataDir + "TaskPriority.mpp", FileMode.Open);
            Project prj = new Project(fs);
            fs.Close();

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Display Priorities for all tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                Console.WriteLine(tsk1.Get(Tsk.Name) + " - Priority : " + tsk1.Get(Tsk.Priority).ToString());
            }
            // ExEnd:ReadTaskPriority
        }
Exemple #25
0
        static void Main(string[] args)
        {
            Project prj = new Project("Project.mpp");

            //Declare ChildTasksCollector class object
            ChildTasksCollector collector = new ChildTasksCollector();

            //Use TaskUtils to get all children tasks in RootTask
            TaskUtils.Apply(prj.RootTask, collector, 0);

            //Define Resources
            ArrayList resources = new ArrayList();

            for (int i = 1; i <= 5; i++)
            {
                string devloper = "Developer0" + i;
                //Create resource
                Resource rec = new Resource(devloper);
                rec.Type = ResourceType.Work;

                //Add resource to project
                prj.Resources.Add(rec);

                //define assignment
                ResourceAssignment ra = new ResourceAssignment((Aspose.Tasks.Task)collector.Tasks[i], rec);
                prj.ResourceAssignments.Add(ra);
            }

            prj.CalcResourceUids();
            prj.CalcResourceIds();
            prj.CalcResourceFields();
            prj.CalcResourceAssignmentUids();
            prj.CalcResourceAssignmentIds();

            prj.Save("Project1_CSharp_Aspose.mpp", Aspose.Tasks.Saving.SaveFileFormat.MPP);
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
        public void IterateOverTaskAssignments()
        {
            // ExStart:IterateOverTaskAssignments
            // ExFor: Task.Assignments
            // ExFor: Task.Equals(Task)
            // ExFor: Task.Equals(Object)
            // ExSummary: Shows how to iterate over task's assignments.
            var project = new Project(DataDir + "BudgetWorkAndCost.mpp");

            var collector = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, collector, 0);
            foreach (var task in collector.Tasks)
            {
                // display task's assignments
                foreach (var assignment in task.Assignments)
                {
                    Console.WriteLine(assignment.ToString());
                }
            }

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

            // Create project instance
            Project prj = new Project(dataDir + "ReadTaskCalendar.mpp");

            // Declare ChildTasksCollector class object
            ChildTasksCollector collector = new ChildTasksCollector();

            // Use TaskUtils to get all children tasks in RootTask
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Parse all the recursive children
            foreach (Task tsk in collector.Tasks)
            {
                Calendar tskCal = tsk.Get(Tsk.Calendar);
                Console.WriteLine("Task calendar name: {0}", tskCal == null ? "None" : tskCal.Name);
            }
            // ExEnd:ReadTaskCalendar
        }
        public static void Run()
        {
            // ExStart:ReadTaskPriority
            // Read project from file stream
            string     dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            FileStream fs      = new FileStream(dataDir + "TaskPriority.mpp", FileMode.Open);
            Project    prj     = new Project(fs);

            fs.Close();

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Display Priorities for all tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                Console.WriteLine(tsk1.Get(Tsk.Name) + " - Priority : " + tsk1.Get(Tsk.Priority).ToString());
            }
            // ExEnd:ReadTaskPriority
        }
        public static void Run()
        {
            // ExStart:ReadTaskOutlineProperties
            // Read project from file stream
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            FileStream fs = new FileStream(dataDir + "TaskOutlineProperties.mpp", FileMode.Open);
            Project prj = new Project(fs);
            fs.Close();

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                Console.WriteLine(tsk1.Get(Tsk.Name) + " - Outline Level : " + tsk1.Get(Tsk.OutlineLevel));
                Console.WriteLine(tsk1.Get(Tsk.Name) + " - Outline Number : " + tsk1.Get(Tsk.OutlineNumber));
            }
            // ExEnd:ReadTaskOutlineProperties
        }
        public static void Run()
        {
            //ExStart:ReadTaskCalendar
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // Create project instance
            Project prj = new Project(dataDir + "ReadTaskCalendar.mpp");

            // Declare ChildTasksCollector class object
            ChildTasksCollector collector = new ChildTasksCollector();

            // Use TaskUtils to get all children tasks in RootTask
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Parse all the recursive children
            foreach (Task tsk in collector.Tasks)
            {
                Calendar tskCal = tsk.Get(Tsk.Calendar);
                Console.WriteLine("Task calendar name: {0}", tskCal == null ? "None" : tskCal.Name);
            }
            //ExEnd:ReadTaskCalendar
        }
        static void Main(string[] args)
        {
            Project prj = new Project("Project.mpp");

            //Declare ChildTasksCollector class object
            ChildTasksCollector collector = new ChildTasksCollector();

            //Use TaskUtils to get all children tasks in RootTask
            TaskUtils.Apply(prj.RootTask, collector, 0);

            //Define Resources
            ArrayList resources = new ArrayList();
            for (int i = 1; i <= 5; i++)
            {
                string devloper = "Developer0" + i;
                //Create resource
                Resource rec = new Resource(devloper);
                rec.Type = ResourceType.Work;

                //Add resource to project
                prj.Resources.Add(rec);

                //define assignment
                ResourceAssignment ra = new ResourceAssignment((Aspose.Tasks.Task)collector.Tasks[i], rec);
                prj.ResourceAssignments.Add(ra);
            }

            prj.CalcResourceUids();
            prj.CalcResourceIds();
            prj.CalcResourceFields();
            prj.CalcResourceAssignmentUids();
            prj.CalcResourceAssignmentIds();

            prj.Save("Project1_CSharp_Aspose.mpp", Aspose.Tasks.Saving.SaveFileFormat.MPP);
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
        public static void Run()
        {
            // ExStart:ReadTaskOutlineProperties
            // Read project from file stream
            string     dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            FileStream fs      = new FileStream(dataDir + "TaskOutlineProperties.mpp", FileMode.Open);
            Project    prj     = new Project(fs);

            fs.Close();

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                Console.WriteLine(tsk1.Get(Tsk.Name) + " - Outline Level : " + tsk1.Get(Tsk.OutlineLevel));
                Console.WriteLine(tsk1.Get(Tsk.Name) + " - Outline Number : " + tsk1.Get(Tsk.OutlineNumber));
            }
            // ExEnd:ReadTaskOutlineProperties
        }
        public static void Run()
        {
            try
            {
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

                //ExStart:CreateResourcesAndLinkToTasks
                Project project1 = new Project(dataDir + "SampleProject.mpp");

                // Declare ChildTasksCollector class object
                ChildTasksCollector collector = new ChildTasksCollector();

                // Use TaskUtils to get all children tasks in RootTask
                TaskUtils.Apply(project1.RootTask, collector, 0);

                // Define Resources
                for (int i = 0; i <= 4; i++)
                {
                    string developer0 = "Developer0" + i;

                    // Add resource to project
                    Resource newResource = project1.Resources.Add(developer0);
                    newResource.Set(Rsc.Type, ResourceType.Work);

                    // Define assignment
                    ResourceAssignment newResourceAssignment = project1.ResourceAssignments.Add(collector.Tasks[i], newResource);
                }

                project1.Save(dataDir + "CreateResourcesAndLinkToTasks_out.mpp", SaveFileFormat.MPP);
                //ExEnd:CreateResourcesAndLinkToTasks
            }
            catch (NotSupportedException ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
            }
        }
        public static void Run()
        {
            // ExStart:GetConstraints
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Project project1 = new Project(dataDir + "Project2.mpp");

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(project1.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Aspose.Tasks.Task tsk1 in collector.Tasks)
            {
                if (tsk1.Get(Tsk.ConstraintDate).ToShortDateString() == "1/1/2000")
                    Console.WriteLine("NA");
                else
                    Console.WriteLine(tsk1.Get(Tsk.ConstraintDate).ToShortDateString());

                Console.WriteLine(tsk1.Get(Tsk.ConstraintType).ToString());
            }
            // ExEnd:GetConstraints
        }
Exemple #35
0
      private void button1_Click(object sender, RibbonControlEventArgs e)
      {
          DateTime currentdate = System.DateTime.Now;

          #region get path and project info

          //get active project and path

          MSPROJECT.Project project1 = Globals.ThisAddIn.Application.ActiveProject;

          string projectpath = project1.Path.ToString();
          projectname = project1.Name.ToString();

          string datadir = projectpath;

          bool baseline_ = false;

          //project1.SaveAs(datadir + "\\" + "temp.mpp");

          DialogResult result = MessageBox.Show("All Projects Will Be Saved and Closed. Proceed?", "Warning",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

          try
          {
              if (result == DialogResult.Yes)
              {
                  Globals.ThisAddIn.Application.FileCloseAllEx(MSPROJECT.PjSaveType.pjSave);

                  Aspose.Tasks.Project prj = new Aspose.Tasks.Project(datadir + "\\" + projectname);

                  // Declare ChildTasksCollector class object
                  ChildTasksCollector collector = new ChildTasksCollector();

                  // Use TaskUtils to get all children tasks in RootTask
                  TaskUtils.Apply(prj.RootTask, collector, 0);

                  //create entity
                  SchedulingEntities db     = new SchedulingEntities();
                  Schedule_Actual    actual = new Schedule_Actual();

                  Schedule_Baseline baseline = new Schedule_Baseline();


                  #region view all tasks

                  DialogResult baselineresult = MessageBox.Show("Create/Update Baseline?", "Warning",
                                                                MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                  if (baselineresult == DialogResult.Yes)
                  {
                      baseline_ = true;
                  }
                  else
                  {
                  }


                  foreach (Task tsk2 in collector.Tasks)
                  {
                      Calendar tskCal   = tsk2.Get(Tsk.Calendar);
                      string   taskinfo = tsk2.ToString();
                      int      id1      = tsk2.Get(Tsk.Id);

                      if (id1 == 0)
                      {
                          string jobnumber = tsk2.Get(Tsk.Name);

                          actual.job        = jobnumber;
                          actual.createdate = currentdate;

                          if (baseline_ == true)
                          {
                              baseline.job        = jobnumber;
                              baseline.createdate = currentdate;
                          }
                      }
                      if (tsk2.Get(Tsk.Name) == "Design")
                      {
                          DateTime designStart = tsk2.Get(Tsk.Start);
                          DateTime designEnd   = tsk2.Get(Tsk.Finish);

                          actual.designend   = designEnd;
                          actual.designstart = designStart;

                          if (baseline_ == true)
                          {
                              baseline.designstart = designStart;
                              baseline.designend   = designEnd;
                          }
                      }

                      if (tsk2.Get(Tsk.Name) == "Processing")
                      {
                          DateTime processingStart = tsk2.Get(Tsk.Start);
                          DateTime processingEnd   = tsk2.Get(Tsk.Finish);

                          actual.processingend   = processingEnd;
                          actual.processingstart = processingStart;

                          if (baseline_ == true)
                          {
                              baseline.processingend   = processingEnd;
                              baseline.processingstart = processingStart;
                          }
                      }

                      if (tsk2.Get(Tsk.Name) == "Weld Fab")
                      {
                          DateTime weldStart = tsk2.Get(Tsk.Start);
                          DateTime weldEnd   = tsk2.Get(Tsk.Finish);

                          actual.weldstart = weldStart;
                          actual.weldend   = weldEnd;

                          if (baseline_ == true)
                          {
                              baseline.weldstart = weldStart;
                              baseline.weldend   = weldEnd;
                          }
                      }

                      if (tsk2.Get(Tsk.Name) == "Machine")
                      {
                          DateTime machineStart = tsk2.Get(Tsk.Start);
                          DateTime machineEnd   = tsk2.Get(Tsk.Finish);

                          actual.machineend   = machineEnd;
                          actual.machinestart = machineStart;

                          if (baseline_ == true)
                          {
                              baseline.machineend   = machineEnd;
                              baseline.machinestart = machineStart;
                          }
                      }

                      if (tsk2.Get(Tsk.Name) == "Assembly")
                      {
                          DateTime assemblyStart = tsk2.Get(Tsk.Start);
                          DateTime assemblyEnd   = tsk2.Get(Tsk.Finish);

                          actual.assemblystart = assemblyStart;
                          actual.assemblyend   = assemblyEnd;

                          if (baseline_ == true)
                          {
                              baseline.assemblyend   = assemblyEnd;
                              baseline.assemblystart = assemblyStart;
                          }
                      }

                      if (tsk2.Get(Tsk.Name) == "QA BUY OFF")
                      {
                          DateTime qaStart = tsk2.Get(Tsk.Start);
                          DateTime qaEnd   = tsk2.Get(Tsk.Finish);

                          actual.qastart = qaStart;
                          actual.qaend   = qaEnd;

                          if (baseline_ == true)
                          {
                              baseline.qaend   = qaEnd;
                              baseline.qastart = qaStart;
                          }
                      }

                      if (tsk2.Get(Tsk.Name) == "Material")
                      {
                          DateTime matStart = tsk2.Get(Tsk.Start);
                          DateTime matEnd   = tsk2.Get(Tsk.Finish);

                          actual.materialstart = matStart;
                          actual.materialend   = matEnd;

                          if (baseline_ == true)
                          {
                              baseline.materialstart = matStart;
                              baseline.materialend   = matEnd;
                          }
                      }
                  }

                  db.Schedule_Actual.Add(actual);

                  if (baseline_ == true)
                  {
                      db.Schedule_Baseline.Add(baseline);
                  }
                  db.SaveChanges();

                  SaveOptions saveOptions = new PdfSaveOptions();
                  saveOptions.PageSize = PageSize.Ledger;
                  saveOptions.SaveFormat.Equals(SaveFileFormat.PDF);
                  saveOptions.FitContent         = true;
                  saveOptions.Timescale          = Timescale.ThirdsOfMonths;
                  saveOptions.PresentationFormat = PresentationFormat.GanttChart;
                  saveOptions.LegendOnEachPage   = false;

                  projectname = projectname.Replace("-", "_");

                  string filename = "R:\\wipviewer2017\\prjfiles\\" + projectname + ".pdf";


                  prj.Save(filename, saveOptions);

                  email_team(filename);
                  PdfPageEditor pEdit = new PdfPageEditor();
              }

              #endregion



              else if (result == DialogResult.No)
              {
                  // DO NOTHING
              }
          }

          catch (Exception ee)
          {
              MessageBox.Show(ee.ToString());
          }
          #endregion
      }
        public void ReadWriteTaskExtendedAttributes()
        {
            try
            {
                // ExStart:ReadWriteTaskExtendedAttributes
                // ExFor: Task.ExtendedAttributes
                // ExSummary: Shows how to read task extended attributes.
                var project = new Project(DataDir + "ReadTaskExtendedAttributes.mpp");

                // Create extended attribute definition
                var definition = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Start, ExtendedAttributeTask.Start7, "Start 7");
                project.ExtendedAttributes.Add(definition);

                // Get zero index task
                var tsk = project.RootTask.Children.GetById(1);

                // Add extended attribute
                var extendedAttribute = definition.CreateExtendedAttribute();
                extendedAttribute.DateValue = DateTime.Now;

                // Also the following short syntax can be used: ExtendedAttribute attribute = attributeDefinition.CreateExtendedAttribute(DateTime.Now);
                tsk.ExtendedAttributes.Add(extendedAttribute);

                // Create an Extended Attribute Definition of Text1 type
                var taskExtendedAttributeText1Definition =
                    ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Text, ExtendedAttributeTask.Text1, "Task City Name");

                // Add it to the project's Extended Attributes collection
                project.ExtendedAttributes.Add(taskExtendedAttributeText1Definition);

                var newTask = project.RootTask.Children.Add("Task 1");

                // Create an Extended Attribute from the Attribute Definition
                var taskExtendedAttributeText1 = taskExtendedAttributeText1Definition.CreateExtendedAttribute();

                // Assign a value to the generated Extended Attribute. The type of the attribute is "Text", the "TextValue" property should be used.
                taskExtendedAttributeText1.TextValue = "London";

                // Add the Extended Attribute to task
                newTask.ExtendedAttributes.Add(taskExtendedAttributeText1);

                // Create an Extended Attribute Definition of Text2 type
                var taskExtendedAttributeText2Definition = ExtendedAttributeDefinition.CreateLookupTaskDefinition(
                    CustomFieldType.Text,
                    ExtendedAttributeTask.Text2,
                    "Task Towns Name");

                // Add lookup values for the extended attribute definition
                taskExtendedAttributeText2Definition.AddLookupValue(new Value {
                    Id = 1, StringValue = "Town1", Description = "This is Town1"
                });
                taskExtendedAttributeText2Definition.AddLookupValue(new Value {
                    Id = 2, StringValue = "Town2", Description = "This is Town2"
                });

                // Add it to the project's Extended Attributes collection
                project.ExtendedAttributes.Add(taskExtendedAttributeText2Definition);

                var task2 = project.RootTask.Children.Add("Task 2");

                // Crate an Extended Attribute from the Text2 Lookup Definition for Id 1
                var taskExtendedAttributeText2 = taskExtendedAttributeText2Definition.CreateExtendedAttribute(taskExtendedAttributeText2Definition.ValueList[1]);

                // Add the Extended Attribute to task
                task2.ExtendedAttributes.Add(taskExtendedAttributeText2);

                // Create an Extended Attribute Definition of Duration2 type
                var taskExtendedAttributeDuration2Definition = ExtendedAttributeDefinition.CreateLookupTaskDefinition(
                    CustomFieldType.Duration,
                    ExtendedAttributeTask.Duration2,
                    "Some duration");

                // Add lookup values for extended attribute definition
                taskExtendedAttributeDuration2Definition.AddLookupValue(
                    new Value {
                    Id = 3, Duration = project.GetDuration(4, TimeUnitType.Hour), Description = "4 hours"
                });
                taskExtendedAttributeDuration2Definition.AddLookupValue(new Value {
                    Id = 4, Duration = project.GetDuration(1, TimeUnitType.Day), Description = "1 day"
                });
                taskExtendedAttributeDuration2Definition.AddLookupValue(
                    new Value {
                    Id = 5, Duration = project.GetDuration(1, TimeUnitType.Hour), Description = "1 hour"
                });
                taskExtendedAttributeDuration2Definition.AddLookupValue(
                    new Value {
                    Id = 6, Duration = project.GetDuration(10, TimeUnitType.Day), Description = "10 days"
                });

                // Add the definition to the project's Extended Attributes collection
                project.ExtendedAttributes.Add(taskExtendedAttributeDuration2Definition);

                var task3 = project.RootTask.Children.Add("Task 3");

                // Create an Extended Attribute from the Duration2 Lookup Definition for Id 3
                var taskExtendedAttributeDuration2 =
                    taskExtendedAttributeDuration2Definition.CreateExtendedAttribute(taskExtendedAttributeDuration2Definition.ValueList[3]);

                // Add the Extended Attribute to task
                task3.ExtendedAttributes.Add(taskExtendedAttributeDuration2);

                // Create an Extended Attribute Definition of Finish2 Type
                var taskExtendedAttributeFinish2Definition = ExtendedAttributeDefinition.CreateLookupTaskDefinition(
                    CustomFieldType.Finish,
                    ExtendedAttributeTask.Finish2,
                    "Some finish");

                // Add lookup values for extended attribute definition
                taskExtendedAttributeFinish2Definition.AddLookupValue(
                    new Value {
                    Id = 7, DateTimeValue = new DateTime(1984, 01, 01, 00, 00, 01), Description = "This is Value2"
                });
                taskExtendedAttributeFinish2Definition.AddLookupValue(
                    new Value {
                    Id = 8, DateTimeValue = new DateTime(1994, 01, 01, 00, 01, 01), Description = "This is Value3"
                });
                taskExtendedAttributeFinish2Definition.AddLookupValue(
                    new Value {
                    Id = 9, DateTimeValue = new DateTime(2009, 12, 31, 00, 00, 00), Description = "This is Value4"
                });
                taskExtendedAttributeFinish2Definition.AddLookupValue(new Value {
                    Id = 10, DateTimeValue = DateTime.Now, Description = "This is Value6"
                });

                // Add the definition to the project's Extended Attributes collection
                project.ExtendedAttributes.Add(taskExtendedAttributeFinish2Definition);

                var task4 = project.RootTask.Children.Add("Task 4");

                // Create an Extended Attribute from the Finish2 Lookup Definition for Id 3
                var taskExtendedAttributeFinish2 = taskExtendedAttributeFinish2Definition.CreateExtendedAttribute(taskExtendedAttributeFinish2Definition.ValueList[3]);

                // Add the Extended Attribute to task
                task4.ExtendedAttributes.Add(taskExtendedAttributeFinish2);

                var collector = new ChildTasksCollector();
                TaskUtils.Apply(project.RootTask, collector, 0);

                // Read extended attributes for tasks
                foreach (var task in collector.Tasks)
                {
                    foreach (var attribute in task.ExtendedAttributes)
                    {
                        Console.WriteLine(attribute.FieldId);
                        Console.WriteLine(attribute.ValueGuid);

                        switch (attribute.AttributeDefinition.CfType)
                        {
                        case CustomFieldType.Date:
                        case CustomFieldType.Start:
                        case CustomFieldType.Finish:
                            Console.WriteLine(attribute.DateValue);
                            break;

                        case CustomFieldType.Text:
                            Console.WriteLine(attribute.TextValue);
                            break;

                        case CustomFieldType.Duration:
                            Console.WriteLine(attribute.DurationValue.ToString());
                            break;

                        case CustomFieldType.Cost:
                        case CustomFieldType.Number:
                            Console.WriteLine(attribute.NumericValue);
                            break;

                        case CustomFieldType.Flag:
                            Console.WriteLine(attribute.FlagValue);
                            break;

                        case CustomFieldType.Null:
                        case CustomFieldType.RBS:
                        case CustomFieldType.OutlineCode:
                            return;

                        default:
                            return;
                        }
                    }
                }

                project.Save(OutDir + "ReadWriteTaskExtendedAttributes_out.mpp", SaveFileFormat.MPP);

                // ExEnd:ReadWriteTaskExtendedAttributes
            }
            catch (NotSupportedException ex)
            {
                Console.WriteLine(
                    ex.Message
                    + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
            }
        }
Exemple #37
0
        public void WorkWithOutlineCodeCollection()
        {
            // ExStart
            // ExFor: OutlineCodeCollection
            // ExFor: OutlineCodeCollection.Add(OutlineCode)
            // ExFor: OutlineCodeCollection.Clear
            // ExFor: OutlineCodeCollection.Contains(OutlineCode)
            // ExFor: OutlineCodeCollection.CopyTo(OutlineCode[],Int32)
            // ExFor: OutlineCodeCollection.Count
            // ExFor: OutlineCodeCollection.GetEnumerator
            // ExFor: OutlineCodeCollection.IndexOf(OutlineCode)
            // ExFor: OutlineCodeCollection.Insert(Int32,OutlineCode)
            // ExFor: OutlineCodeCollection.IsReadOnly
            // ExFor: OutlineCodeCollection.Item(Int32)
            // ExFor: OutlineCodeCollection.Remove(OutlineCode)
            // ExFor: OutlineCodeCollection.RemoveAt(Int32)
            // ExSummary: Shows how to work with outline code collections.
            var project = new Project(DataDir + "OutlineCodes2003.mpp");

            var collector = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, collector, 0);

            for (var i = 0; i < collector.Tasks.Count; i++)
            {
                var current = collector.Tasks[i];
                if (current.Get(Tsk.Id) == 0)
                {
                    continue;
                }

                Console.WriteLine("Print outline codes for the " + current.Get(Tsk.Name) + " task.");
                Console.WriteLine("Count of outline codes: " + current.OutlineCodes.Count);
                foreach (var outlineCode in current.OutlineCodes)
                {
                    Console.WriteLine("Field Id: " + outlineCode.FieldId);
                    Console.WriteLine("Value Id: " + outlineCode.ValueId);
                    Console.WriteLine("Value Guid: " + outlineCode.ValueGuid);
                    Console.WriteLine();
                }
            }

            // add a custom outline code definition
            var outlineCodeDefinition = new OutlineCodeDefinition {
                FieldId = ((int)ExtendedAttributeTask.OutlineCode3).ToString("D"), Alias = "My Outline Code"
            };

            project.OutlineCodes.Add(outlineCodeDefinition);

            // create outline code
            var value = new OutlineValue {
                Type = OutlineValueType.Text, Value = "Val1", Description = "Descr1", ValueId = 1
            };

            outlineCodeDefinition.Values.Add(value);

            var codeOne = new OutlineCode {
                FieldId = outlineCodeDefinition.FieldId, ValueId = 1, ValueGuid = value.ValueGuid.ToString("D").ToUpperInvariant()
            };

            var task = project.RootTask.Children.GetByUid(2);

            // one can check that collection is not read only
            if (!task.OutlineCodes.IsReadOnly)
            {
                task.OutlineCodes.Add(codeOne);
            }

            var codeZero = new OutlineCode {
                FieldId = outlineCodeDefinition.FieldId, ValueId = 0, ValueGuid = value.ValueGuid.ToString("D").ToUpperInvariant()
            };

            task.OutlineCodes.Insert(0, codeZero);

            var code2 = new OutlineCode {
                FieldId = outlineCodeDefinition.FieldId, ValueId = 2, ValueGuid = value.ValueGuid.ToString("D").ToUpperInvariant()
            };

            // insert code with 2 in a wrong position
            task.OutlineCodes.Insert(0, code2);

            // fix it
            var indexOf = task.OutlineCodes.IndexOf(code2);

            task.OutlineCodes.RemoveAt(indexOf);

            // insert code with 2 in a right position
            task.OutlineCodes.Insert(2, code2);

            // check that the code was inserted
            Console.WriteLine("Is outline codes contains the inserted value: " + task.OutlineCodes.Contains(code2));

            // ...
            // work with outline codes
            // ...
            var otherProject = new Project(DataDir + "OutlineCodes2003.mpp");
            var otherTask    = otherProject.RootTask.Children.GetById(2);

            // add a custom outline code definition
            outlineCodeDefinition = new OutlineCodeDefinition {
                FieldId = ((int)ExtendedAttributeTask.OutlineCode3).ToString("D"), Alias = "My Outline Code"
            };
            otherProject.OutlineCodes.Add(outlineCodeDefinition);

            // create outline code
            var otherValue = new OutlineValue {
                Type = OutlineValueType.Text, Value = "Val1", Description = "Descr1", ValueId = 1
            };

            outlineCodeDefinition.Values.Add(otherValue);

            var outlineCodes = new OutlineCode[task.OutlineCodes.Count];

            task.OutlineCodes.CopyTo(outlineCodes, 0);

            foreach (var code in outlineCodes)
            {
                otherTask.OutlineCodes.Add(code);
            }

            // ...
            // work with outline codes
            // ...

            // remove outline code
            otherTask.OutlineCodes.RemoveAt(0);

            while (otherTask.OutlineCodes.Count > 0)
            {
                otherTask.OutlineCodes.Remove(otherTask.OutlineCodes[0]);
            }

            // clear all values at once
            task.OutlineCodes.Clear();

            // ExEnd
        }