예제 #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());
        }
예제 #2
0
        public WhatIfResult OnComplete(ProjectItem projectItem, DateTime completedDate, bool addNewPeriodics)
        {
            Assertion.Require(projectItem, "projectItem");

            this.whatIfResult = new WhatIfResult(projectItem, ProjectItemOperation.Complete);

            // Add root state change
            var stateChange = new ProjectItemStateChange(projectItem, ProjectItemOperation.Complete)
            {
                ActualEndDate = completedDate
            };

            whatIfResult.AddStateChange(stateChange);

            // Update related
            UpdateRelatedProjectItemsDeadlines(projectItem, completedDate);


            if (addNewPeriodics)
            {
                var newPeriodicResult = ModelingServices.TryGetNextPeriodic(projectItem, completedDate);

                if (newPeriodicResult != null)
                {
                    this.whatIfResult.AddStateChanges(newPeriodicResult.StateChanges);
                }
            }

            return(this.whatIfResult);
        }
예제 #3
0
        static public void Reactivate(ProjectItem projectItem)
        {
            Assertion.Require(projectItem, "projectItem");

            WhatIfResult result = ModelingServices.WhatIfReactivated(projectItem);

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

            StoreChanges(result);
        }
예제 #4
0
        static private void CreateNextPeriodicIfNecessary(ProjectItem projectItem, DateTime completedDate)
        {
            var nextPeriodicResult = ModelingServices.TryGetNextPeriodic(projectItem, completedDate);

            if (nextPeriodicResult == null)
            {
                return;
            }

            StoreChanges(nextPeriodicResult);

            projectItem.Project.MoveTo(nextPeriodicResult.StateChanges[0].ProjectItem,
                                       TreeItemInsertionRule.AsSiblingAfterInsertionPoint, projectItem);
        }
예제 #5
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());
        }
예제 #6
0
 private WhatIfResult GetNewModelResult()
 {
     return(ModelingServices.WhatIfCreatedFromEvent(this.ProcessDefinitionRootItem,
                                                    this.Project, this.RootProjectItem.Deadline));
 }