protected model.WorkflowItem RecursiveCompare(model.WorkflowItem item)
        {
            if (item?.Childs != null || item.Childs.Any())
            {
                foreach (var chld in item.Childs)
                {
                    RecursiveCompare(chld);
                }
            }
            if (item.State != item.CalculatedState && item is model.Project)
            {
                item.State = item.CalculatedState;
                switch (item.State)
                {
                case model.WorkflowState.Planned:
                    item.StartDate = item.FinishDate = null;
                    break;

                case model.WorkflowState.InProgress:
                    item.StartDate = DateTime.Now;
                    break;

                case model.WorkflowState.Completed:
                    item.FinishDate = DateTime.Now;
                    break;
                }
                _persistAction(item);
            }
            return(item);
        }
Example #2
0
        private async Task <model.WorkflowItem> TraverseAsync(model.WorkflowItem item)
        {
            await Entry(item).Collection(i => i.Childs).LoadAsync();

            foreach (var chld in item.Childs)
            {
                await TraverseAsync(chld);
            }
            return(item);
        }
Example #3
0
        public async Task <model.Project> GetWholeTreeAsync(int id)
        {
            model.WorkflowItem item = Projects.Find(id);
            if (item == null)
            {
                item = Tasks.Find(id);
            }
            if (item == null)
            {
                return(null);
            }
            await Entry(item).Reference(i => i.Parent).LoadAsync();

            while (item.Parent != null)
            {
                item = item.Parent;
                await Entry(item).Reference(i => i.Parent).LoadAsync();
            }
            ;

            item = await TraverseAsync(item);

            return(item as model.Project); //tree root is a project only
        }