Exemple #1
0
        static public FixedList <ProjectItem> Complete(ProjectItem projectItem, DateTime completedDate)
        {
            Assertion.Require(projectItem, "projectItem");

            WhatIfResult result = ModelingServices.WhatIfCompleted(projectItem, completedDate, false);

            if (result.HasErrors)
            {
                throw result.GetException();
            }

            if (!String.IsNullOrWhiteSpace(projectItem.ProcessID))
            {
                ProjectItemData.ResetSubprocessID(projectItem.ProcessID);
            }

            StoreChanges(result);

            CreateNextPeriodicIfNecessary(projectItem, completedDate);
            ProjectItemData.ClearProcessID();

            projectItem.Project.Refresh();


            return(projectItem.Project.GetItems());
        }
Exemple #2
0
        static public FixedList <ProjectItem> CreateActivitiesFromModel(Activity activityModel,
                                                                        Project project,
                                                                        DateTime eventDate,
                                                                        ProjectItem insertionPoint,
                                                                        TreeItemInsertionRule insertionRule)
        {
            Assertion.Require(activityModel, "activityModel");
            Assertion.Require(project, "project");
            Assertion.Require(insertionPoint, "insertionPoint");

            WhatIfResult result = ModelingServices.WhatIfCreatedFromEvent(activityModel, project, eventDate);

            if (result.HasErrors)
            {
                throw result.GetException();
            }

            ProjectItemData.ResetProcessID();

            StoreChanges(result);

            ProjectItemData.ClearProcessID();

            if (result.StateChanges.Count > 0)
            {
                if (!insertionPoint.IsEmptyInstance && insertionRule != TreeItemInsertionRule.AsTreeRootAtEnd)
                {
                    project.MoveTo(result.StateChanges[0].ProjectItem, insertionRule, insertionPoint);
                }
                else if (insertionPoint.IsEmptyInstance && (insertionRule == TreeItemInsertionRule.AsTreeRootAtStart ||
                                                            insertionRule == TreeItemInsertionRule.AsTreeRootAtEnd))
                {
                    project.MoveTo(result.StateChanges[0].ProjectItem, insertionRule, insertionPoint);
                }
            }
            return(project.GetItems());
        }