Exemplo n.º 1
0
        private string GetFieldNameForCurrentUserInfo(SourceFieldNode node)
        {
            var fieldName = node.FieldName;

            if (node.ParentNode != null)
            {
                var listName = node.ParentNode.FieldName + ".";
                fieldName = string.Format("{0}GetValueByPropertyNameForExpression(\"{1}\")", listName, fieldName.Replace(listName, ""));
            }

            return fieldName;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Visits the specified node.
 /// </summary>
 /// <param name="node">The node.</param>
 public void Visit(SourceFieldNode node)
 {
     VisitConstantNode(node);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the name of the field.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="isTopLevel">if set to <c>true</c> [is top level].</param>
        /// <returns>System.String.</returns>
        private string GetFieldName(SourceFieldNode node, bool isTopLevel = true)
        {
            if (node.SetName == SourceFieldSetNames.IntegrationServiceSourceItem || node.SetName == SourceFieldSetNames.IntegrationServiceResultItem)
            {
                var path = node.GetFullPath();

                if (DestinationNodeContext.Current != null)
                {
                    var resultNode = DestinationNodeContext.Current.Node as ResultNode;

                    if (resultNode != null
                        && (resultNode.DataType == NodeDataType.List || resultNode.DataType == NodeDataType.Array
                            || resultNode.DataType == NodeDataType.Checklist || resultNode.DataType == NodeDataType.Sample))
                    {
                        return string.Format("context.EnumerateItems(\"{0}\")", path);
                    }

                    if (IsAggregateFunction(DestinationNodeContext.Current.Node) && node == GetAggregateFunctionListParameter(DestinationNodeContext.Current.Node))
                    {
                        return string.Format("context.EnumerateItems(\"{0}\")", path);
                    }
                }

                return string.Format("context.GetPropertyValue(\"{0}\")", path);
            }

            if (node.SetName == SourceFieldSetNames.IntegrationWebMethodCallSourceItem)
            {
                var path = node.GetFullPath();

                if (DestinationNodeContext.Current != null)
                {
                    var resultNode = DestinationNodeContext.Current.Node as ResultNode;

                    if (resultNode != null && resultNode.DataType == NodeDataType.Array)
                    {
                        return string.Format("context.EnumerateItems(\"{0}\")", path);
                    }

                    if (IsAggregateFunction(DestinationNodeContext.Current.Node) && node == GetAggregateFunctionListParameter(DestinationNodeContext.Current.Node))
                    {
                        return string.Format("context.EnumerateItems(\"{0}\")", path);
                    }
                }

                return string.Format("context.GetPropertyValue(\"{0}\")", path);
            }

            if (node.SetName == SourceFieldSetNames.IntegrationWebMethodCallResultItem)
            {
                var path = node.GetFullPath(Constants.WebMethodCallResultFieldSeparator);

                if (DestinationNodeContext.Current != null)
                {
                    var resultNode = DestinationNodeContext.Current.Node as ResultNode;

                    if (resultNode != null && resultNode.DataType == NodeDataType.List)
                    {
                        return string.Format("context.EnumerateItems(\"{0}\")", path);
                    }

                    if (IsAggregateFunction(DestinationNodeContext.Current.Node) && node == GetAggregateFunctionListParameter(DestinationNodeContext.Current.Node))
                    {
                        return string.Format("context.EnumerateItems(\"{0}\")", path);
                    }
                }

                return string.Format("context.GetPropertyValue(\"{0}\")", path);
            }

            if (node.SetName == SourceFieldSetNames.MsaItem)
            {
                var path = node.PropertyPath;

                if (node.ParentNode != null)
                    path = string.Format("{0}{1}", GetFieldName(node.ParentNode, false), 
                                                   string.IsNullOrEmpty(path) ? string.Empty : "." + path);

                return path;
            }

            var fieldName = (node.PropertyPath ?? node.FieldName).Replace(" ", string.Empty);
            var parent = string.IsNullOrEmpty(node.ObjectName) ? "this" : node.ObjectName;

            if (node.ParentNode != null)
            {
                parent = string.Format("{0}", GetFieldName(node.ParentNode, false));
            }

            switch (node.DataType)
            {
                case NodeDataType.Boolean:
                    if (node.SetName == SourceFieldSetNames.Item)
                        fieldName = string.Format("((bool?){1}.GetValueByPropertyNameForExpression(\"{0}\"))", fieldName, parent);
                    if (node.SetName == SourceFieldSetNames.CurrentUserInfo)
                        fieldName = string.Format("((bool?){0})", GetFieldNameForCurrentUserInfo(node));
                    
                    // Don't change the value for esync. If it's null, let it return null.
                    if (node.SetName == SourceFieldSetNames.ESyncSourceItem)
                        fieldName = string.Format("((bool?){1}.GetValueByPropertyName(\"{0}\"))", node.FieldName, parent);

                    if (node.SetName == SourceFieldSetNames.DataTriggerSourceItem)
                        fieldName = string.Format("((bool?){1}.GetValueByPropertyName(\"{0}\"))", node.FieldName, parent);

                    break;
                case NodeDataType.DateTime:
                    if (node.SetName == SourceFieldSetNames.Item)
                        fieldName = string.Format("((System.DateTime?){1}.GetValueByPropertyNameForExpression(\"{0}\"))", fieldName, parent);
                    if (node.SetName == SourceFieldSetNames.CurrentUserInfo)
                        fieldName = string.Format("((System.DateTime?){0})", GetFieldNameForCurrentUserInfo(node));
                    
                    // Don't change the value for esync. If it's null, let it return null.
                    if (node.SetName == SourceFieldSetNames.ESyncSourceItem)
                        fieldName = string.Format("((System.DateTime?){1}.GetValueByPropertyName(\"{0}\"))", node.FieldName, parent);

                    if (node.SetName == SourceFieldSetNames.DataTriggerSourceItem)
                        fieldName = string.Format("((System.DateTime?){1}.GetValueByPropertyName(\"{0}\"))", node.FieldName, parent);
 
                    break;

                case NodeDataType.CrossReference:
                    if (node.SetName == SourceFieldSetNames.Item)
                    {
                        if (isTopLevel)
                            fieldName = string.Format("((int?)((IDynamicObject){1}).GetCrossReferenceIdByPropertyName(\"{0}\"))", fieldName, parent);
                        else
                            fieldName = string.Format("((object){1}.GetValueByPropertyNameForExpression(\"{0}\"))", fieldName, parent);
                    }

                    if (node.SetName == SourceFieldSetNames.DataTriggerSourceItem)
                    {
                        if (isTopLevel)
                            fieldName = string.Format("((int?)((IDynamicObject){1}).GetCrossReferenceIdByPropertyName(\"{0}\"))", fieldName, parent);
                        else
                            fieldName = string.Format("((IDynamicObject){1}.GetCrossReferenceMemberByPropertyName(\"{0}\"))", fieldName, parent);
                    }

                    break;

                case NodeDataType.ReverseCrossReference:
                    if (node.SetName == SourceFieldSetNames.Item)
                    {
                        if (isTopLevel)
                            fieldName = string.Format("((int?)((IDynamicObject)((IDynamicObject){1}).GetValueByPropertyName(\"{0}\")).GetValueByPropertyName(\"Id\"))", fieldName, parent);
                        else
                            fieldName = string.Format("((object){1}.GetValueByPropertyNameForExpression(\"{0}\"))", fieldName, parent);
                    }

                    if (node.SetName == SourceFieldSetNames.DataTriggerSourceItem)
                    {
                        if (isTopLevel)
                            fieldName = string.Format("((int?)((IDynamicObject)((IDynamicObject){1}).GetValueByPropertyName(\"{0}\")).GetValueByPropertyName(\"Id\"))", fieldName, parent);
                        else
                            fieldName = string.Format("((IDynamicObject){1}.GetValueByPropertyNameForExpression(\"{0}\"))", fieldName, parent);
                    }

                    break;

                case NodeDataType.File:
                    {
                        fieldName = string.Format("((IDynamicObject)((IDynamicObject){1}).GetValueByPropertyName(\"{0}\"))", fieldName, parent);
                    }

                    break;

                case NodeDataType.SPCChart:
                    if (node.SetName == SourceFieldSetNames.Item)
                        fieldName = string.Format("\"{0}\", {1}.GetSpcProperty(\"{0}\")", fieldName, parent);
                    break;

                case NodeDataType.Frequency:
                    {
                        fieldName = string.Format(
                            CultureInfo.InvariantCulture,
                            "((IDynamicObject){1}).GetValueByPropertyName(\"{0}{2}\")",
                            fieldName,
                            parent,
                            Constants.FrequencyEventInfoFieldSuffix);
                    }

                    break;

                default:
                    if (node.SetName == SourceFieldSetNames.Item)
                        fieldName = string.Format("{1}.GetValueByPropertyNameForExpression(\"{0}\")", fieldName, parent);
                    if (node.SetName == SourceFieldSetNames.CurrentUserInfo)
                        fieldName = string.Format("{0}", GetFieldNameForCurrentUserInfo(node));

                    // Don't change the value for esync.
                    if (node.SetName == SourceFieldSetNames.ESyncSourceItem)
                        fieldName = string.Format("{1}.GetValueByPropertyName(\"{0}\")", node.FieldName, parent);

                    if (node.SetName == SourceFieldSetNames.DataTriggerSourceItem)
                        fieldName = string.Format("{1}.GetValueByPropertyName(\"{0}\")", node.FieldName, parent);
                    break;
            }

            return fieldName;
        }