Example #1
0
        public IList <IDev2Definition> GenerateDefsFromDataList(string dataList, enDev2ColumnArgumentDirection dev2ColumnArgumentDirection)
        {
            IList <IDev2Definition> result = new List <IDev2Definition>();

            if (!string.IsNullOrEmpty(dataList))
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(dataList);

                XmlNodeList tmpRootNl = xDoc.ChildNodes;
                XmlNodeList nl        = tmpRootNl[0].ChildNodes;

                for (int i = 0; i < nl.Count; i++)
                {
                    XmlNode tmpNode = nl[i];

                    var ioDirection = GetDev2ColumnArgumentDirection(tmpNode);

                    if (CheckIODirection(dev2ColumnArgumentDirection, ioDirection))
                    {
                        if (tmpNode.HasChildNodes)
                        {
                            // it is a record set, make it as such
                            string recordsetName = tmpNode.Name;
                            // now extract child node defs
                            XmlNodeList childNl = tmpNode.ChildNodes;
                            for (int q = 0; q < childNl.Count; q++)
                            {
                                var xmlNode          = childNl[q];
                                var fieldIODirection = GetDev2ColumnArgumentDirection(xmlNode);
                                if (CheckIODirection(dev2ColumnArgumentDirection, fieldIODirection))
                                {
                                    result.Add(DataListFactory.CreateDefinition(xmlNode.Name, "", "", recordsetName, false, "",
                                                                                false, "", false));
                                }
                            }
                        }
                        else
                        {
                            // scalar value, make it as such
                            result.Add(DataListFactory.CreateDefinition(tmpNode.Name, "", "", false, "", false, ""));
                        }
                    }
                }
            }

            return(result);
        }
Example #2
0
        private void CheckForRecordsetsInInputMapping(IList <IDev2Definition> result, XmlNode tmp, string value, string origValue, bool isEvaluated, string mapsTo, string defaultValue, bool isRequired, bool emptyToNull, XmlNode recordSetNode)
        {
            var theName = tmp.Attributes[_nameAttribute].Value;

            if (_defaultValueToMapsTo)
            {
                var recordSet = recordSetNode.Value;
                // we have a recordset set it as such
                result.Add(DataListFactory.CreateDefinition(theName, mapsTo, value, recordSet, isEvaluated, defaultValue, isRequired, origValue, emptyToNull));
            }
            else
            {
                // if record set add as such
                var recordSet = recordSetNode.Value;
                result.Add(DataListFactory.CreateDefinition(tmp.Attributes[_nameAttribute].Value, mapsTo, value, recordSet, isEvaluated, defaultValue, isRequired, origValue, emptyToNull));
            }
        }
Example #3
0
        private void EvaluateOutputMapsTo(IList <IDev2Definition> result, XmlNode node)
        {
            // extract default value if present
            var defaultValue = string.Empty;

            XmlNode defaultValNode = node.Attributes[_defaultValueAttribute];

            if (defaultValNode != null)
            {
                defaultValue = defaultValNode.Value;
            }

            // extract EmptyToNull
            var     emptyToNull = false;
            XmlNode emptyNode   = node.Attributes[_emptyToNullAttribute];

            if (emptyNode != null)
            {
                bool.TryParse(emptyNode.Value, out emptyToNull);
            }

            // extract isRequired
            var isRequired = IsRequired(node.ChildNodes);

            XmlNode recordSetNode = node.Attributes[_recordSetAttribute];

            if (recordSetNode != null)
            {
                result.Add(DataListFactory.CreateDefinition_Recordset(node.Attributes[_nameAttribute].Value, _nodeMapsTo, _nodeValue, recordSetNode.Value, _isNodeEvaluated, defaultValue, isRequired, _originalNodeValue, emptyToNull));
            }
            else
            {
                var dev2Definition = Dev2Definition.NewObject(node.Attributes[_nameAttribute].Value, _nodeMapsTo, _nodeValue, _isNodeEvaluated, defaultValue, isRequired, _originalNodeValue, emptyToNull);

                if (node.Attributes["IsObject"] == null || !bool.TryParse(node.Attributes["IsObject"].Value, out bool isObject))
                {
                    isObject = false;
                }
                dev2Definition.IsObject = isObject;
                result.Add(dev2Definition);
            }
        }
        private void AddValidNodes(IList <IDev2DataLanguageIntellisensePart> result, XmlNodeList nl)
        {
            for (int i = 0; i < nl.Count; i++)
            {
                var tmpNode = nl[i];

                if (IsValidChildNode(tmpNode))
                {
                    var recordsetName = tmpNode.Name;
                    IList <IDev2DataLanguageIntellisensePart> children = new List <IDev2DataLanguageIntellisensePart>();
                    var childNl = tmpNode.ChildNodes;
                    for (int q = 0; q < childNl.Count; q++)
                    {
                        children.Add(DataListFactory.CreateIntellisensePart(childNl[q].Name, ExtractDescription(childNl[q])));
                    }
                    if (FilterTO.FilterType == enIntellisensePartType.None)
                    {
                        result.Add(DataListFactory.CreateIntellisensePart(recordsetName, ExtractDescription(tmpNode), children));
                    }
                    if (FilterTO.FilterType == enIntellisensePartType.RecordsetsOnly)
                    {
                        result.Add(DataListFactory.CreateIntellisensePart(string.Concat(recordsetName, "()"), ExtractDescription(tmpNode)));
                    }
                    if (FilterTO.FilterType == enIntellisensePartType.RecordsetFields)
                    {
                        result.Add(DataListFactory.CreateIntellisensePart(recordsetName, ExtractDescription(tmpNode), children));
                    }
                }
                else
                {
                    if (FilterTO.FilterType == enIntellisensePartType.None || FilterTO.FilterType == enIntellisensePartType.ScalarsOnly)
                    {
                        result.Add(DataListFactory.CreateIntellisensePart(tmpNode.Name, ExtractDescription(tmpNode)));
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// Generates the wizard data list from defs.
        /// </summary>
        /// <param name="definitions">The definitions.</param>
        /// <param name="defType">Type of the def.</param>
        /// <param name="pushToServer">if set to <c>true</c> [push to server].</param>
        /// <param name="errors">The errors.</param>
        /// <param name="withData"></param>
        /// <returns></returns>
        public StringBuilder GenerateWizardDataListFromDefs(string definitions, enDev2ArgumentType defType, bool pushToServer, out ErrorResultTO errors, bool withData = false)
        {
            IList <IDev2Definition> defs;
            IList <IDev2Definition> wizdefs = new List <IDev2Definition>();

            if (defType == enDev2ArgumentType.Output)
            {
                defs = OutputParser.ParseAndAllowBlanks(definitions);

                foreach (IDev2Definition def in defs)
                {
                    wizdefs.Add(def.IsRecordSet ? DataListFactory.CreateDefinition(def.RecordSetName + GlobalConstants.RecordsetJoinChar + def.Name, def.MapsTo, def.Value, def.IsEvaluated, def.DefaultValue, def.IsRequired, def.RawValue) : DataListFactory.CreateDefinition(def.Name, def.MapsTo, def.Value, def.IsEvaluated, def.DefaultValue, def.IsRequired, def.RawValue));
                }
            }
            else if (defType == enDev2ArgumentType.Input)
            {
                defs = InputParser.Parse(definitions);
                foreach (IDev2Definition def in defs)
                {
                    wizdefs.Add(def.IsRecordSet ? DataListFactory.CreateDefinition(def.RecordSetName + GlobalConstants.RecordsetJoinChar + def.Name, def.MapsTo, def.Value, def.IsEvaluated, def.DefaultValue, def.IsRequired, def.RawValue) : DataListFactory.CreateDefinition(def.Name, def.MapsTo, def.Value, def.IsEvaluated, def.DefaultValue, def.IsRequired, def.RawValue));
                }
            }

            return(GenerateDataListFromDefs(wizdefs, pushToServer, out errors, withData));
        }
        /// <summary>
        /// Generates this instance.
        /// </summary>
        /// <returns></returns>
        public IList <IDev2DataLanguageIntellisensePart> Generate()
        {
            IList <IDev2DataLanguageIntellisensePart> result = new List <IDev2DataLanguageIntellisensePart>();

            XmlDocument xDoc = new XmlDocument();
            // ReSharper disable TooWideLocalVariableScope
            string rawRecsetName;

            // ReSharper restore TooWideLocalVariableScope
            if (FilterTO == null)
            {
                FilterTO = new IntellisenseFilterOpsTO();
            }
            if (FilterTO.FilterCondition != null)
            {
                rawRecsetName = FilterTO.FilterCondition;
                if (rawRecsetName.Contains("[["))
                {
                    rawRecsetName = rawRecsetName.Replace("[[", "");
                }
                if (rawRecsetName.Contains("]]"))
                {
                    rawRecsetName = rawRecsetName.Replace("]]", "");
                }
                if (rawRecsetName.Contains("()"))
                {
                    // ReSharper disable RedundantAssignment
                    rawRecsetName = rawRecsetName.Replace("()", "");
                    // ReSharper restore RedundantAssignment
                }
            }


            if (!string.IsNullOrEmpty(DataList))
            {
                XmlNodeList tmpRootNl = null;

                try
                {
                    xDoc.LoadXml(DataList);
                    tmpRootNl = xDoc.ChildNodes;
                }
                catch (Exception ex)
                {
                    Dev2Logger.Log.Error(ex);
                }

                if (tmpRootNl != null)
                {
                    XmlNodeList nl = tmpRootNl[0].ChildNodes;
                    for (int i = 0; i < nl.Count; i++)
                    {
                        XmlNode tmpNode = nl[i];

                        if (IsValidChildNode(tmpNode))
                        {
                            // it is a record set, make it as such
                            string recordsetName = tmpNode.Name;
                            IList <IDev2DataLanguageIntellisensePart> children = new List <IDev2DataLanguageIntellisensePart>();
                            // now extract child node defs
                            XmlNodeList childNl = tmpNode.ChildNodes;
                            for (int q = 0; q < childNl.Count; q++)
                            {
                                children.Add(DataListFactory.CreateIntellisensePart(childNl[q].Name, ExtractDescription(childNl[q])));
                            }
                            if (FilterTO.FilterType == enIntellisensePartType.All)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(recordsetName, ExtractDescription(tmpNode), children));
                            }
                            if (FilterTO.FilterType == enIntellisensePartType.RecordsetsOnly)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(string.Concat(recordsetName, "()"), ExtractDescription(tmpNode)));
                            }
                            if (FilterTO.FilterType == enIntellisensePartType.RecordsetFields)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(recordsetName, ExtractDescription(tmpNode), children));
                            }
                        }
                        else
                        {
                            // scalar value, make it as such
                            if (FilterTO.FilterType == enIntellisensePartType.All || FilterTO.FilterType == enIntellisensePartType.ScalarsOnly)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(tmpNode.Name, ExtractDescription(tmpNode)));
                            }
                        }
                    }
                }
            }


            return(result);
        }
Example #7
0
        internal IList <IDev2Definition> Parse(string mappingDefinition, bool ignoreBlanks = true)
        {
            IList <IDev2Definition> result = new List <IDev2Definition>();

            if (!string.IsNullOrEmpty(mappingDefinition))
            {
                XmlDocument xDoc = new XmlDocument();

                xDoc.LoadXml(mappingDefinition);

                XmlNodeList tmpList = xDoc.GetElementsByTagName(_elementTag);

                for (int i = 0; i < tmpList.Count; i++)
                {
                    XmlNode tmp       = tmpList[i];
                    string  value     = string.Empty;
                    string  origValue = string.Empty;

                    XmlNode valueNode = tmp.Attributes[_valueTag];
                    if (valueNode != null)
                    {
                        value     = valueNode.Value;
                        origValue = value;
                    }

                    // is it evaluated?
                    bool   isEvaluated = false;
                    string mapsTo      = tmp.Attributes[_mapsToAttribute].Value;


                    if (!_defaultValueToMapsTo)
                    { // output
                        // account for blank mapsto in generated output defs
                        if (mapsTo == string.Empty)
                        {
                            XmlNode xn = tmp.Attributes[_outputMapsToAdjust];
                            if (xn != null)
                            {
                                mapsTo = xn.Value;
                            }
                        }

                        if (mapsTo.Contains(_magicEval))
                        {
                            isEvaluated = true;
                            mapsTo      = mapsTo.Replace(_magicEval, "").Replace("]]", "");
                        }
                        if (value.Contains(_magicEval))
                        {
                            value       = value.Replace(_magicEval, "").Replace("]]", "");
                            isEvaluated = true;
                        }
                    }
                    else
                    {
                        // input
                        origValue = mapsTo;
                        value     = mapsTo;
                        if (value.Contains(_magicEval))
                        {
                            isEvaluated = true;
                            value       = value.Replace(_magicEval, "").Replace("]]", "");
                            mapsTo      = value;
                        }
                    }

                    // extract default value if present
                    string defaultValue = string.Empty;

                    XmlNode defaultValNode = tmp.Attributes[_defaultValueAttribute];
                    if (defaultValNode != null)
                    {
                        defaultValue = defaultValNode.Value;
                    }

                    // extract isRequired
                    bool isRequired = false;

                    XmlNodeList nl = tmp.ChildNodes;
                    if (nl.Count > 0)
                    {
                        int pos = 0;
                        while (pos < nl.Count && !isRequired)
                        {
                            if (nl[pos].Name == _validateTag)
                            {
                                XmlNode requiredValidationNode = nl[pos].Attributes[_validateTypeAttribute];
                                if (requiredValidationNode != null && requiredValidationNode.Value == _requiredValidationAttributeValue)
                                {
                                    isRequired = true;
                                }
                            }
                            pos++;
                        }
                    }

                    // extract EmptyToNull
                    bool    emptyToNull = false;
                    XmlNode emptyNode   = tmp.Attributes[_emptyToNullAttribute];
                    if (emptyNode != null)
                    {
                        Boolean.TryParse(emptyNode.Value, out emptyToNull);
                    }

                    // only create if mapsTo is not blank!!
                    if ((!ignoreBlanks || (mapsTo != string.Empty && value != string.Empty)) || _defaultValueToMapsTo)
                    {
                        if (!_defaultValueToMapsTo) // Outputs only
                        {
                            if (String.IsNullOrEmpty(mapsTo))
                            {
                                continue;
                            }
                        }
                        XmlNode recordSetNode = tmp.Attributes[_recordSetAttribute];

                        if (recordSetNode != null)
                        {
                            // check for recordsets on input mapping

                            var theName = tmp.Attributes[_nameAttribute].Value;
                            if (_defaultValueToMapsTo)
                            {
                                string recordSet = recordSetNode.Value;
                                // we have a recordset set it as such
                                result.Add(DataListFactory.CreateDefinition(theName, mapsTo, value, recordSet, isEvaluated, defaultValue, isRequired, origValue, emptyToNull));
                            }
                            else
                            {
                                // if record set add as such
                                string recordSet = recordSetNode.Value;
                                result.Add(DataListFactory.CreateDefinition(tmp.Attributes[_nameAttribute].Value, mapsTo, value, recordSet, isEvaluated, defaultValue, isRequired, origValue, emptyToNull));
                            }
                        }
                        else
                        {
                            result.Add(DataListFactory.CreateDefinition(tmp.Attributes[_nameAttribute].Value, mapsTo, value, isEvaluated, defaultValue, isRequired, origValue, emptyToNull));
                        }
                    }
                }
            }

            return(result);
        }
Example #8
0
        void ParseMappingDefinition(string mappingDefinition, bool ignoreBlanks, IList <IDev2Definition> result)
        {
            var xDoc = new XmlDocument();

            xDoc.LoadXml(mappingDefinition);

            var tmpList = xDoc.GetElementsByTagName(_elementTag);

            foreach (XmlNode tmp in tmpList)
            {
                var value     = string.Empty;
                var origValue = string.Empty;

                XmlNode valueNode = tmp.Attributes[_valueTag];
                if (valueNode != null)
                {
                    value     = valueNode.Value;
                    origValue = value;
                }

                // is it evaluated?
                var isEvaluated = false;
                var mapsTo      = tmp.Attributes[_mapsToAttribute].Value;

                if (tmp.Attributes["IsObject"] == null || !bool.TryParse(tmp.Attributes["IsObject"].Value, out bool isObject))
                {
                    isObject = false;
                }

                if (!_defaultValueToMapsTo)
                { // output
                    // account for blank mapsto in generated output defs
                    if (mapsTo == string.Empty)
                    {
                        mapsTo = GetMapsTo(tmp);
                    }

                    if (mapsTo.Contains(_magicEval))
                    {
                        isEvaluated = true;
                        mapsTo      = mapsTo.Replace(_magicEval, "").Replace("]]", "");
                    }
                    if (value.Contains(_magicEval))
                    {
                        value       = value.Replace(_magicEval, "").Replace("]]", "");
                        isEvaluated = true;
                    }
                }
                else
                {
                    // input
                    origValue = mapsTo;
                    value     = mapsTo;
                    if (value.Contains(_magicEval))
                    {
                        isEvaluated = true;
                        value       = value.Replace(_magicEval, "").Replace("]]", "");
                        mapsTo      = value;
                    }
                }

                // extract default value if present
                var defaultValue = string.Empty;

                XmlNode defaultValNode = tmp.Attributes[_defaultValueAttribute];
                if (defaultValNode != null)
                {
                    defaultValue = defaultValNode.Value;
                }

                // extract isRequired
                var isRequired = false;

                var nl = tmp.ChildNodes;
                if (nl.Count > 0)
                {
                    isRequired = GetChildNodes(isRequired, nl);
                }

                // extract EmptyToNull
                var     emptyToNull = false;
                XmlNode emptyNode   = tmp.Attributes[_emptyToNullAttribute];
                if (emptyNode != null)
                {
                    Boolean.TryParse(emptyNode.Value, out emptyToNull);
                }

                // only create if mapsTo is not blank!!
                if (!ignoreBlanks || mapsTo != string.Empty && value != string.Empty || _defaultValueToMapsTo)
                {
                    if (!_defaultValueToMapsTo && String.IsNullOrEmpty(mapsTo)) // Outputs only
                    {
                        continue;
                    }

                    XmlNode recordSetNode = tmp.Attributes[_recordSetAttribute];

                    if (recordSetNode != null)
                    {
                        CheckForRecordsetsInInputMapping(result, tmp, value, origValue, isEvaluated, mapsTo, defaultValue, isRequired, emptyToNull, recordSetNode);
                    }
                    else
                    {
                        var dev2Definition = DataListFactory.CreateDefinition(tmp.Attributes[_nameAttribute].Value, mapsTo, value, isEvaluated, defaultValue, isRequired, origValue, emptyToNull);
                        dev2Definition.IsObject = isObject;
                        result.Add(dev2Definition);
                    }
                }
            }
        }