コード例 #1
0
ファイル: ToolConflictRow.cs プロジェクト: tuga1975/Warewolf
 internal static ToolConflictRow CreateConflictRow(IToolConflictItem currentToolConflictItem, IToolConflictItem diffToolConflictItem, List <IConnectorConflictRow> connectors) => new ToolConflictRow
 {
     CurrentViewModel = currentToolConflictItem,
     DiffViewModel    = diffToolConflictItem,
     Connectors       = connectors,
     HasConflict      = !currentToolConflictItem.Equals(diffToolConflictItem)
 };
コード例 #2
0
        IList <IConnectorConflictRow> CreateStartNodeConnectors(IToolConflictItem currentConflictItem, IToolConflictItem differentConflictItem, ConflictTreeNode current, ConflictTreeNode diff)
        {
            const string key       = "Start";
            var          emptyGuid = Guid.Empty;
            var          row       = new ConnectorConflictRow
            {
                Key           = key,
                ContainsStart = true
            };

            if (current == null)
            {
                row.CurrentArmConnector = new ConnectorConflictItem.Empty(emptyGuid);
            }
            else
            {
                var connector = new ConnectorConflictItem(this, Column.Current, row.UniqueId, "Start -> " + current.Activity.GetDisplayName(), emptyGuid, Guid.Parse(current.UniqueId), key);
                row.CurrentArmConnector = connector;
                currentConflictItem.OutboundConnectors.Add(connector);
            }
            if (diff == null)
            {
                row.DifferentArmConnector = new ConnectorConflictItem.Empty(emptyGuid);
            }
            else
            {
                var connector = new ConnectorConflictItem(this, Column.Different, row.UniqueId, "Start -> " + diff.Activity.GetDisplayName(), emptyGuid, Guid.Parse(diff.UniqueId), key);
                row.DifferentArmConnector = connector;
                differentConflictItem.OutboundConnectors.Add(connector);
            }
            return(new List <IConnectorConflictRow> {
                row
            });
        }
コード例 #3
0
ファイル: ToolConflictRow.cs プロジェクト: tuga1975/Warewolf
 internal static ToolConflictRow CreateStartRow(IToolConflictItem currentToolConflictItem, IToolConflictItem diffToolConflictItem) => new ToolConflictRow
 {
     CurrentViewModel = currentToolConflictItem,
     DiffViewModel    = diffToolConflictItem,
     ContainsStart    = true,
     IsMergeVisible   = false,
     HasConflict      = false
 };
コード例 #4
0
        void GetToolConflictItems(ConflictTreeNode current, ConflictTreeNode diff, bool diffFoundInCurrent, bool currFoundInDifferent)
        {
            if (!diffFoundInCurrent && !currFoundInDifferent)
            {
                //This is a guard clause
                // NOTE: if we want to allow a tool that was deleted to not conflict with a tool that was added
                // this is where it would be implemented
            }
            else
            {
                if (!diffFoundInCurrent)
                {
                    currentToolConflictItem = ToolConflictItem.EmptyConflictItem();
                }
                if (!currFoundInDifferent)
                {
                    diffToolConflictItem = ToolConflictItem.EmptyConflictItem();
                }
            }

            if (currentToolConflictItem == null)
            {
                if (current == null)
                {
                    currentToolConflictItem = ToolConflictItem.EmptyConflictItem();
                }
                else
                {
                    currentToolConflictItem = new ToolConflictItem(_list, ConflictRowList.Column.Current);
                    _modelFactoryCurrent.CreateModelItem(currentToolConflictItem, current);
                }
                indexCurr++;
            }
            if (diffToolConflictItem == null)
            {
                if (diff == null)
                {
                    diffToolConflictItem = ToolConflictItem.EmptyConflictItem();
                }
                else
                {
                    diffToolConflictItem = new ToolConflictItem(_list, ConflictRowList.Column.Different);
                    _modelFactoryDifferent.CreateModelItem(diffToolConflictItem, diff);
                }
                indexDiff++;
            }
        }
コード例 #5
0
        public List <ToolConflictRow> CreateList(ConflictRowList list, ConflictTreeNode[] currentTree, ConflictTreeNode[] diffTree)
        {
            var _currentTree = currentTree;
            var _diffTree    = diffTree;

            _list = list;

            var toolConflictRowList = new List <ToolConflictRow>();

            indexDiff = 0;
            indexCurr = 0;

            for (int i = 0; i <= MAX_WORKFLOW_ITEMS; i++)
            {
                if (i == MAX_WORKFLOW_ITEMS)
                {
                    Dev2Logger.Error("ConflictRowListBuilder.CreateList: createlist expected to advance", GlobalConstants.WarewolfError);
                    throw new Exception("createlist expected to advance");
                }
                ConflictTreeNode current = null;
                ConflictTreeNode diff    = null;

                current = GetConflictTreeNode(true, indexCurr, indexDiff, _currentTree);
                diff    = GetConflictTreeNode(false, indexCurr, indexDiff, _diffTree);
                if (current == null && diff == null)
                {
                    break;
                }
                currentToolConflictItem = null;
                diffToolConflictItem    = null;
                bool diffFoundInCurrent   = _currentTree.Contains(diff);
                bool currFoundInDifferent = _diffTree.Contains(current);

                if (diffFoundInCurrent && currFoundInDifferent)
                {
                    diff    = _diffTree.FirstOrDefault(o => o.UniqueId == current.UniqueId);
                    current = _currentTree.FirstOrDefault(o => o.UniqueId == current.UniqueId);
                }
                GetToolConflictItems(current, diff, diffFoundInCurrent, currFoundInDifferent);

                var toolConflictRow = BuildToolConflictRow(list, current, diff);
                toolConflictRow.IsMergeVisible = toolConflictRow.HasConflict;
                toolConflictRowList.Add(toolConflictRow);
            }
            return(toolConflictRowList);
        }
コード例 #6
0
        public void RemoveItem(IToolConflictItem model)
        {
            var root  = _wd.Context.Services.GetService <ModelService>().Root;
            var chart = _wd.Context.Services.GetService <ModelService>().Find(root, typeof(Flowchart)).FirstOrDefault();

            var nodes = chart?.Properties["Nodes"]?.Collection;

            if (nodes == null)
            {
                return;
            }
            model.IsAddedToWorkflow = false;
            var step = model.FlowNode;

            switch (step)
            {
            case FlowStep normalStep:
                if (nodes.Contains(normalStep))
                {
                    normalStep.Next = null;
                    nodes.Remove(normalStep);
                }

                break;

            case FlowDecision normalDecision:
                if (nodes.Contains(normalDecision))
                {
                    nodes.Remove(normalDecision);
                }

                break;

            case FlowSwitch <string> normalSwitch:
                nodes.Remove(normalSwitch);
                break;

            default:
                break;
            }
        }
コード例 #7
0
        private static void SetInitialConnectorRowState(IConnectorConflictRow row)
        {
            bool sourceConflict      = row.CurrentArmConnector.SourceUniqueId != row.DifferentArmConnector.SourceUniqueId;
            bool destinationConflict = row.CurrentArmConnector.DestinationUniqueId != row.DifferentArmConnector.DestinationUniqueId;

            IToolConflictItem destinationToolCurrent   = null;
            IToolConflictItem destinationToolDifferent = null;

            if (!(row.CurrentArmConnector is ConnectorConflictItem.Empty))
            {
                destinationToolCurrent = row.CurrentArmConnector.DestinationConflictItem();
            }
            if (!(row.DifferentArmConnector is ConnectorConflictItem.Empty))
            {
                destinationToolDifferent = row.DifferentArmConnector.DestinationConflictItem();
            }

            var destinationToolConflict = destinationToolCurrent != null && destinationToolDifferent != null && !destinationToolCurrent.Equals(destinationToolDifferent);
            var keyConflict             = row.CurrentArmConnector.Key != row.DifferentArmConnector.Key;

            row.HasConflict = sourceConflict || destinationConflict || destinationToolConflict || keyConflict;
        }
コード例 #8
0
        public void LinkStartNode(IToolConflictItem model)
        {
            if (model == null)
            {
                return;
            }
            var root  = _wd.Context.Services.GetService <ModelService>().Root;
            var chart = _wd.Context.Services.GetService <ModelService>().Find(root, typeof(Flowchart)).FirstOrDefault();

            var nodes = chart?.Properties["Nodes"]?.Collection;

            if (nodes == null)
            {
                return;
            }
            var startNode = chart.Properties["StartNode"];

            if (startNode != null && startNode.ComputedValue == null)
            {
                startNode.SetValue(model.FlowNode);
                Selection.Select(_wd.Context, ModelItemUtils.CreateModelItem(model.FlowNode));
            }
        }
コード例 #9
0
        public void AddItem(IToolConflictItem model)
        {
            var service = _workflowDesignerHelper.GetService <ModelService>(_wd);
            var root    = service.Root;
            var chart   = _workflowDesignerHelper.GetService <ModelService>(_wd).Find(root, typeof(Flowchart)).FirstOrDefault();

            var nodes = chart?.Properties["Nodes"]?.Collection;

            if (nodes == null)
            {
                return;
            }

            var nodeToAdd = model.ModelItem;
            var step      = model.FlowNode;

            switch (step)
            {
            case FlowStep normalStep:
                normalStep.Next = null;
                if (!nodes.Contains(normalStep))
                {
                    nodes.Add(normalStep);
                }
                break;

            case FlowDecision normalDecision:
                normalDecision.DisplayName = model.MergeDescription;
                normalDecision.False       = null;
                normalDecision.True        = null;
                nodes.Add(normalDecision);
                break;

            case FlowSwitch <string> normalSwitch:
                var switchAct = new DsfFlowSwitchActivity
                {
                    ExpressionText = String.Join("", GlobalConstants.InjectedSwitchDataFetch,
                                                 "(\"", nodeToAdd.GetProperty <string>("Switch"), "\",",
                                                 GlobalConstants.InjectedDecisionDataListVariable,
                                                 ")"),
                    UniqueID = nodeToAdd.GetProperty <string>("UniqueID")
                };
                normalSwitch.DisplayName = model.MergeDescription;
                normalSwitch.Expression  = switchAct;
                normalSwitch.Cases.Clear();
                normalSwitch.Default = null;
                nodes.Add(normalSwitch);
                break;

            default:
                break;
            }
            var modelItem = GetItemFromNodeCollection(model.UniqueId);

            if (modelItem == null)
            {
                return;
            }
            SetShapeLocation(modelItem, model.NodeLocation);
            model.IsAddedToWorkflow = true;
        }
コード例 #10
0
        private List <IConnectorConflictRow> GetConnectorConflictRows(ConflictRowList list, IToolConflictItem currentConflictItem, IToolConflictItem diffConflictItem, ConflictTreeNode current, ConflictTreeNode diff)
        {
            var rows  = new List <IConnectorConflictRow>();
            int index = 0;
            var armConnectorsCurrent = new List <(string Description, string Key, string SourceUniqueId, string DestinationUniqueId)>();
            var armConnectorsDiff    = new List <(string Description, string Key, string SourceUniqueId, string DestinationUniqueId)>();

            SetConnectorConflict(current, diff, out armConnectorsCurrent, out armConnectorsDiff, out int maxCount);

            for (; index < maxCount; index++)
            {
                row = new ConnectorConflictRow();
                row.CurrentArmConnector = new ConnectorConflictItem.Empty(row.UniqueId);
                if (armConnectorsCurrent != null && index < armConnectorsCurrent.Count)
                {
                    SetCurrentConnectorConflict(armConnectorsCurrent[index], list, currentConflictItem);
                }
                row.DifferentArmConnector = new ConnectorConflictItem.Empty(row.UniqueId);
                if (armConnectorsDiff != null && index < armConnectorsDiff.Count)
                {
                    SetDiffConnectorConflict(armConnectorsDiff[index], list, diffConflictItem);
                }
                var sameSourceAndDestination = row.CurrentArmConnector.SourceUniqueId != row.DifferentArmConnector.SourceUniqueId || row.CurrentArmConnector.DestinationUniqueId != row.DifferentArmConnector.DestinationUniqueId;
                row.HasConflict = sameSourceAndDestination;
                rows.Add(row);
            }
            return(rows);
        }
コード例 #11
0
 public ConflictModelFactory(IToolConflictItem toolConflictItem, IContextualResourceModel resourceModel, IConflictTreeNode conflict)
 {
     _resourceModel = resourceModel;
     CreateModelItem(toolConflictItem, conflict);
 }