static IDebugTreeViewItemViewModel CreateItemViewModel <T>(IEnvironmentRepository envRepository, int n, bool isSelected, IDebugTreeViewItemViewModel parent)
            where T : IDebugTreeViewItemViewModel
        {
            if (typeof(T) == typeof(DebugStateTreeViewItemViewModel))
            {
                var content = new DebugState {
                    DisplayName = "State " + n, ID = Guid.NewGuid(), ActivityType = ActivityType.Step
                };
                var viewModel = new DebugStateTreeViewItemViewModel(envRepository)
                {
                    Parent = parent, Content = content
                };
                if (!isSelected)
                {
                    // viewModel.IsSelected is true when the ActivityType is Step
                    viewModel.IsSelected = false;
                }
                return(viewModel);
            }

            return(new DebugStringTreeViewItemViewModel
            {
                Content = "String " + n,
                IsSelected = isSelected
            });
        }
 IDebugTreeViewItemViewModel CreateParentTreeViewItem(IDebugState content, IDebugTreeViewItemViewModel child)
 {
     if (!_contentItemMap.TryGetValue(content.ParentID.GetValueOrDefault(), out IDebugTreeViewItemViewModel parent))
     {
         parent = new DebugStateTreeViewItemViewModel(ServerRepository)
         {
             ActivityTypeName = content.ActualType
         };
         _contentItemMap.Add(content.ParentID.GetValueOrDefault(), parent);
     }
     child.Parent = parent;
     parent.Children.Add(child);
     return(parent);
 }
        static void AddErrorToAssertResultListParent(DebugStateTreeViewItemViewModel theParent, object listItem)
        {
            var lineItem = listItem as DebugLine;

            if (lineItem?.LineItems != null)
            {
                foreach (var lineItemLineItem in lineItem.LineItems)
                {
                    if (lineItemLineItem is DebugLineItem line && line.TestStepHasError)
                    {
                        theParent.AppendError(line.Value);
                    }
                }
            }
        }
        IDebugTreeViewItemViewModel CreateChildTreeViewItem(IDebugState content)
        {
            IDebugTreeViewItemViewModel child;

            if (content.StateType == StateType.Message)
            {
                child = new DebugStringTreeViewItemViewModel
                {
                    Content          = content.Message,
                    ActivityTypeName = content.ActualType
                };
            }
            else
            {
                child = new DebugStateTreeViewItemViewModel(ServerRepository)
                {
                    Content          = content,
                    ActivityTypeName = content.ActualType
                };
            }
            return(child);
        }
Example #5
0
        void AddItemToTreeImpl(IDebugState content)
        {
            if ((DebugStatus == DebugStatus.Stopping || DebugStatus == DebugStatus.Finished || _allDebugReceived) && string.IsNullOrEmpty(content.Message) && !_continueDebugDispatch && !_dispatchLastDebugState)
            {
                return;
            }
            Dev2Logger.Log.Debug(string.Format("Debug content to be added ID: {0}" + Environment.NewLine + "Parent ID: {1}" + Environment.NewLine + "Name: {2}", content.ID, content.ParentID, content.DisplayName));
            if (_lastStep != null && DebugStatus == DebugStatus.Finished && content.StateType == StateType.Message)
            {
                var lastDebugStateProcessed = _lastStep;
                _lastStep = null;
                _dispatchLastDebugState = true;
                AddItemToTreeImpl(new DebugState {
                    StateType = StateType.Message, Message = Resources.CompilerMessage_ExecutionInterrupted, ParentID = lastDebugStateProcessed.ParentID
                });
                AddItemToTreeImpl(lastDebugStateProcessed);
                _dispatchLastDebugState = false;
            }

            if (!string.IsNullOrWhiteSpace(SearchText) && !_debugOutputFilterStrategy.Filter(content, SearchText))
            {
                return;
            }

            if (content.StateType == StateType.Message && content.ParentID == Guid.Empty)
            {
                RootItems.Add(new DebugStringTreeViewItemViewModel {
                    Content = content.Message
                });
            }
            else
            {
                var isRootItem = content.ParentID == Guid.Empty || content.ID == content.ParentID;

                IDebugTreeViewItemViewModel child;

                if (content.StateType == StateType.Message)
                {
                    child = new DebugStringTreeViewItemViewModel {
                        Content = content.Message
                    };
                }
                else
                {
                    child = new DebugStateTreeViewItemViewModel(EnvironmentRepository)
                    {
                        Content = content
                    };
                }

                if (!_contentItemMap.ContainsKey(content.ID))
                {
                    _contentItemMap.Add(content.ID, child);
                }
                if (isRootItem)
                {
                    RootItems.Add(child);
                }
                else
                {
                    IDebugTreeViewItemViewModel parent;
                    if (!_contentItemMap.TryGetValue(content.ParentID, out parent))
                    {
                        parent = new DebugStateTreeViewItemViewModel(EnvironmentRepository);
                        _contentItemMap.Add(content.ParentID, parent);
                    }
                    child.Parent = parent;
                    parent.Children.Add(child);
                    if (child.HasError.GetValueOrDefault(false))
                    {
                        var theParent = parent as DebugStateTreeViewItemViewModel;
                        if (theParent == null)
                        {
                            return;
                        }
                        theParent.AppendError(content.ErrorMessage);
                        theParent.HasError = true;
                    }
                }
            }
            if (content.IsFinalStep())
            {
                DebugStatus = DebugStatus.Finished;
            }
        }