public void TestConnectorProperties()
        {
            var obj = new FunctionExpression();
            TestsHelper.TestPublicPropertiesGetSet(obj);

            Assert.IsNotNull(obj.ConnectorOut);
        }
        public void GetConnectorsTest()
        {
            var source = new FunctionExpression
                             {
                                 ConnectorOut = {Name = "4"}
                             };

            var conn = source.GetConnectors();
            Assert.IsTrue(conn.Any(x => x.Name == "4"));
        }
        public void IsValidTest()
        {
            var source = new FunctionExpression();

            Assert.IsFalse(source.IsValid);
            
            Assert.IsFalse(source.IsValid);

            source.ConnectorOut.ConnectedTo = new ConnectorIn(null);
            Assert.IsTrue(source.IsValid);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FunctionExpressionNode"/> class.
        /// </summary>
        /// <param name="diagramViewModel">The diagram view model.</param>
        /// <param name="expressionObject">The expression object.</param>
        /// <exception cref="System.ArgumentNullException">expressionObject</exception>
        public FunctionExpressionNode(IDiagramViewModel diagramViewModel, FunctionExpression expressionObject)
            : base(expressionObject)
        {
            if (expressionObject == null) throw new ArgumentNullException("expressionObject");

            _diagramViewModel = diagramViewModel;

            IsValidFunc = n => true;
            UpdateAction = n => { };

            ConnectorOut = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.Out, expressionObject.ConnectorOut), _diagramViewModel);
        }
        public void CloneTest()
        {
            var source = new FunctionExpression {ExpressionName = "source", Width = 1, Height = 2, Top = 3, Left = 4, ConnectorOut = {Name = "4"}};

            var cloneTo = (FunctionExpression)source.Clone();
            Assert.AreEqual(source.ExpressionName, cloneTo.ExpressionName);
            Assert.AreEqual(source.Width, cloneTo.Width);
            Assert.AreEqual(source.Height, cloneTo.Height);
            Assert.AreEqual(source.Top, cloneTo.Top);
            Assert.AreEqual(source.Left, cloneTo.Left);

            Assert.AreNotEqual(source.Id, cloneTo.Id);
            Assert.AreNotEqual(source.ConnectorOut.Id, cloneTo.ConnectorOut.Id);

            Assert.AreEqual(source.ConnectorOut.Name, cloneTo.ConnectorOut.Name);
        }
        public void TestConnectorSerialization()
        {
            var obj = new FunctionExpression {FunctionName = "test"};

            var tw = new StringWriter();
            using (var xw = XmlWriter.Create(tw))
            {
                xw.WriteStartElement("Node");
                obj.Serialize(xw);
                xw.WriteEndElement();
            }

            var sr = new StringReader(tw.ToString());
            using (var wr = XmlReader.Create(sr))
            {
                wr.ReadToFollowing("Node");
                var result = new FunctionExpression();
                result.Deserialize(wr);

                Assert.AreEqual(obj.Id, result.Id);
                Assert.AreEqual(obj.ConnectorOut.Id, result.ConnectorOut.Id);
                Assert.AreEqual(obj.FunctionName, result.FunctionName);
            }
        }
        public void ValidationMessageTest()
        {
            var source = new FunctionExpression
                             {
                                 ConnectorOut = {Name = "co"}
                             };

            Assert.IsFalse(string.IsNullOrEmpty(source.ValidationMessage));

            source.ConnectorOut.ConnectedTo = new ConnectorIn(null);
            Assert.IsTrue(string.IsNullOrEmpty(source.ValidationMessage));
        }
Beispiel #8
0
        private static void SetupExpressionsDiagram(DiagramViewModel vm)
        {
            vm.Palette.Add(new NodeGroup("String Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.ToUpper)
                                                        {
                                                            ExpressionName = "Uppercase",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.ToLower)
                                                        {
                                                            ExpressionName = "Lowercase",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.Trim)
                                                        {
                                                            ExpressionName = "Trim",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Concat)
                                                        {
                                                            ExpressionName = "Concat",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Left)
                                                        {
                                                            ExpressionName = "Left",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } 
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Right)
                                                        {
                                                            ExpressionName = "Right",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    )
                                                }));

            vm.Palette.Add(new NodeGroup("Date Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.AddDays)
                                                        {
                                                            ExpressionName = "Add Days",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Days Count" },
                                                            ConnectorOut = { DataType = NodeDataType.DateTime, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.DateDiffDays)
                                                        {
                                                            ExpressionName = "DateDiff Days",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date 1" },
                                                            Connector2In = { DataType = NodeDataType.DateTime, Name = "Date 2" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.DateDiffHours)
                                                        {
                                                            ExpressionName = "DateDiff Hours",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date 1" },
                                                            Connector2In = { DataType = NodeDataType.DateTime, Name = "Date 2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FunctionExpressionNode, ExpressionConnection>(
                                                        new FunctionExpressionNode(vm, new FunctionExpression(ExpressionNodeType.CustomFunction)
                                                        {
                                                            ExpressionName = "Current Date",
                                                            FunctionName = "DateTime.Now",
                                                            ConnectorOut = { DataType = NodeDataType.DateTime, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateYear)
                                                        {
                                                            ExpressionName = "Date Year",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Year" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateQuarter)
                                                        {
                                                            ExpressionName = "Date Quarter",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Quarter" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateMonth)
                                                        {
                                                            ExpressionName = "Date Month",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Month" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateMonthName)
                                                        {
                                                            ExpressionName = "Date Month Name",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Month Name" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateWeek)
                                                        {
                                                            ExpressionName = "Date Week",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Week" }
                                                        }),
                                                        vm
                                                    ),

                                                }));

            vm.Palette.Add(new NodeGroup("Logical Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.IsLess)
                                                        {
                                                            ExpressionName = "Less",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.IsGreater)
                                                        {
                                                            ExpressionName = "Greater",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.AreEqual)
                                                        {
                                                            ExpressionName = "Equals",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<ThreeInOneOutExpressionNode, ExpressionConnection>(
                                                        new ThreeInOneOutExpressionNode(vm, new ThreeInOneOutExpression(ExpressionNodeType.If)
                                                        {
                                                            ExpressionName = "Condition",
                                                            Connector1In = { DataType = NodeDataType.Boolean, Name = "Condition" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "When True"  },
                                                            Connector3In = { DataType = NodeDataType.String, Name = "When False" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("Aggregate Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Add)
                                                        {
                                                            ExpressionName = "Add", 
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1"},
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2"},
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Subtract)
                                                        { 
                                                            ExpressionName = "Subtract",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Multiply)
                                                        {
                                                            ExpressionName = "Multiply",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Divide)
                                                        {
                                                            ExpressionName = "Divide",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.CustomFunction)
                                                        {
                                                            ExpressionName = "Custom Multiply",
                                                            FunctionName = "?1 * ?2",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("SPC Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.AboveCenterLine)
                                                        {
                                                            ExpressionName = "Above Center Line", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.BelowCenterLine)
                                                        {
                                                            ExpressionName = "Below Center Line", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.GoingDown)
                                                        {
                                                            ExpressionName = "Going Down", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.GoingUp)
                                                        {
                                                            ExpressionName = "Going Up", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.AlternatingUpAndDown)
                                                        {
                                                            ExpressionName = "Alternating Up and Down", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.LessThanLowerLimits)
                                                        {
                                                            ExpressionName = "Less Than LCL/LSL", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "LCL/LSL"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector5In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.GreaterThanUpperLimits)
                                                        {
                                                            ExpressionName = "Greater Than UCL/USL", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "UCL/USL"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector5In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.Same)
                                                        {
                                                            ExpressionName = "Same", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.Between)
                                                        {
                                                            ExpressionName = "Between", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Double, Name = "Low Value"},
                                                            Connector5In = { DataType = NodeDataType.Double, Name = "High Value"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneAorBeyond)
                                                        {
                                                            ExpressionName = "Zone A or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneBorBeyond)
                                                        {
                                                            ExpressionName = "Zone B or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneCorBeyond)
                                                        {
                                                            ExpressionName = "Zone C or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.FailedNumber)
                                                        {
                                                            ExpressionName = "Failed Number (attribute)", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Number of samples"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.FailedPercent)
                                                        {
                                                            ExpressionName = "Failed Percent (attribute)", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Number of samples"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("Constants",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<ConstantExpressionNode, ExpressionConnection>(
                                                        new ConstantExpressionNode(vm, new ConstantExpression()
                                                        {
                                                            ExpressionName = "Constant",
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    )
                                                }));


            var uis = new SourceFieldList {ExpressionName = "Current User Information", Left = 10, Top = 400};
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "User Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserName", ConnectorOut = { DataType = NodeDataType.String, Name = "User Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Full Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserFullName", ConnectorOut = { DataType = NodeDataType.String, Name = "Full Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.Int, Name = "Person ID", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserPersonId", ConnectorOut = { DataType = NodeDataType.String, Name = "Person ID" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Email Address", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserEmailAddress", ConnectorOut = { DataType = NodeDataType.String, Name = "Email Address" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Last Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserLastName", ConnectorOut = { DataType = NodeDataType.String, Name = "Last Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Business Unit", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserBusinessUnitId", ConnectorOut = { DataType = NodeDataType.String, Name = "Business Unit" } });

            // source
            //var fieldList = new Dictionary<string, object>();
            //fieldList["Name"] = "Name";
            //fieldList["Title"] = "Title";
            //fieldList["PublishDate"] = DateTime.Now;
            //fieldList["Author"] = "Author";

            var sourceNodeList = new SourceFieldList();

            //Func<IExpressionField, ICollection<IExpressionField>> sfRetriever = f => GetCRFields(f, sourceNodeList);
            
            sourceNodeList.ExpressionName = "Album";
            sourceNodeList.Top = 10;
            sourceNodeList.Left = 10;
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Name", SetName = SourceFieldSetNames.Item, SystemName = "Name", ConnectorOut = { DataType = NodeDataType.String, Name = "Name" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Title", SetName = SourceFieldSetNames.Item, SystemName = "Title", ConnectorOut = { DataType = NodeDataType.String, Name = "Title" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "PublishDate", SetName = SourceFieldSetNames.Item, SystemName = "PublishDate", ConnectorOut = { DataType = NodeDataType.String, Name = "PublishDate" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList)
                                          {
                                              DataType = NodeDataType.String, 
                                              Name = "Author", 
                                              SetName = SourceFieldSetNames.Item, 
                                              SystemName = "Author", 
                                              ConnectorOut = { DataType = NodeDataType.String, Name = "Author" },
                                              SubfieldsRetriever = new CRSubfieldsRetriever()
                                          });



            //var sourceNodes = SourceNodeFactory.ConvertToSource("Album", fieldList, SourceFieldSetNames.Item);
            //sourceNodes.Top = 10;
            //sourceNodes.Left = 10;
            //sourceNodes.Width = 200;

            // destination
            var destinationNodes = DestinationNodeFactory.ConvertToSource(typeof(ExpressionResult));
            destinationNodes.Top = 200;
            destinationNodes.Left = 600 ;

            var expressions = new List<IExpressionObjectBase>();
            expressions.Add(sourceNodeList);
            //expressions.Add(uis);
            expressions.Add(destinationNodes);

            // connection
            var connection = new Connection
                                 {
                                     Id = Guid.NewGuid(),
                                     Source = new ConnectorOut(null) { Id = sourceNodeList.ConnectorsOut[0].Id },
                                     Sink = new ConnectorIn(null) { Id = destinationNodes.ConnectorsIn[0].Id }
                                 };
            //expressions.Add(connection);

            // constant
            var constantExpr = new ConstantExpression { ExpressionName = "Constant", Top = 10, Left = 250, Value = 10,
                                                        ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            //expressions.Add(constantExpr);

            // oneinoneout
            var oneinoneoutExpr = new OneInOneOutExpression(ExpressionNodeType.ToUpper)
                                      { ExpressionName = "Uppercase", Top = 60, Left = 250, 
                                        ConnectorIn = {DataType = NodeDataType.String, Name = "String"},
                                        ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                      };
            //expressions.Add(oneinoneoutExpr);

            // twoinoneout
            var twoinoneoutExpr = new TwoInOneOutExpression(ExpressionNodeType.Concat)
            {
                ExpressionName = "Concat",
                Top = 110,
                Left = 250,
                Connector1In = { DataType = NodeDataType.String, Name = "String" },
                Connector2In = { DataType = NodeDataType.String, Name = "String" },
                ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            //expressions.Add(twoinoneoutExpr);

            // threeinoneout
            var threeinoneoutExpr = new ThreeInOneOutExpression(ExpressionNodeType.If)
            {
                ExpressionName = "Condition",
                Top = 180,
                Left = 250,
                Connector1In = { DataType = NodeDataType.Boolean, Name = "Condition" },
                Connector2In = { DataType = NodeDataType.String, Name = "If True" },
                Connector3In = { DataType = NodeDataType.String, Name = "If False" },
                ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            expressions.Add(threeinoneoutExpr);

            // function
            var functionExpr = new FunctionExpression(ExpressionNodeType.CustomFunction) { ExpressionName = "Current Date", Top = 280, Left = 250, Width = 100, Height = 45, FunctionName = "DateTime.Now",
                                ConnectorOut = {DataType = NodeDataType.DateTime, Name="Result"}};
            //expressions.Add(functionExpr);

            ExpressionTranslator.TranslateToDiagram(expressions, vm);
        }
        public void CustomFunctionNodeTest()
        {
            var obj = new ExpressionNodeFactory();
            var connection = new Connection();
            connection.Source = new ConnectorOut(connection);
            connection.Sink = new ConnectorIn(connection);

            var destination = new DestinationFieldList { UniqueName = "Destination" };
            destination.Fields.Add(new DestinationField(destination));
            var source = new FunctionExpression { FunctionName = "Function" };

            destination.Fields[0].ConnectorIn.Id = connection.Sink.Id;
            source.ConnectorOut.Id = connection.Source.Id;

            var objects = new List<IExpressionObjectBase>
                              {   
                                  source,
                                  destination,
                                  connection
                              };

            var destNode = obj.CreateExpressionNodes(objects);
            var sourceNode = destNode.ResultNodes.FirstOrDefault().Expression as CustomFunctionNode;

            Assert.AreEqual("Function", sourceNode.FunctionName);
        }
 /// <summary>
 /// Adds the field node.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="diagramViewModel">The diagram view model.</param>
 private static void AddFieldNode(FunctionExpression item, IDiagramViewModel diagramViewModel)
 {
     var dfl = new FunctionExpressionNode(diagramViewModel, item);
     diagramViewModel.Items.Add(new NodeViewModel<FunctionExpressionNode, ExpressionConnection>(dfl, diagramViewModel));
 }
Beispiel #11
0
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>ExpressionObjectBase.</returns>
        public override ExpressionObjectBase Clone()
        {
            var clone = new FunctionExpression(Type)
                            {
                                ExpressionName = ExpressionName, FunctionName = FunctionName,
                                Width = Width,
                                Height = Height,
                                Top = Top,
                                Left = Left
                            };
            ConnectorOut.Clone(clone.ConnectorOut);

            return clone;
        }