Ejemplo n.º 1
0
        /// <summary>
        /// Add data in the EDI segment
        /// </summary>
        /// <param name="segment">Segment</param>
        /// <param name="node">Node with the configuration</param>
        /// <param name="handler">Orquestator</param>
        /// <param name="section">Parent Section</param>
        /// <param name="output">Output</param>
        /// <returns>Objeto con los datos</returns>
        public IEDISegment GetEDISegment(IEDISegment segment, XmlNode node, OwlHandler handler, SectionOutput section, GenericOutput output)
        {
            foreach (XmlNode nElement in handler.ConfigMap.GetNotHiddenOutputElements(node))
            {
                ElementOutput element = (ElementOutput)handler.XOMLValidator.GetXOMLObject(new ElementOutput(), nElement, handler);
                output.GetElementValue(element, nElement, section);
                SetProperty(element.Name, segment, element.Value);
            }

            return(segment);
        }
Ejemplo n.º 2
0
        protected override string GenerateSection(SectionOutput section, XmlNode node)
        {
            #region Separators

            if (validateSeparator)
            {
                _structureEDI      = (EDIStructureOutput)_currentEstructuraOutput;
                _segmentProperties = new EDISegmentProperties {
                    DecimalSeparator = _structureEDI.OutputDecimalSeparator
                };

                if (_structureEDI.SegmentSeparator == char.MinValue)
                {
                    _structureEDI.SegmentSeparator = _segmentProperties.SegmentSeparator;
                }
                else if (_structureEDI.SegmentSeparator != _segmentProperties.SegmentSeparator)
                {
                    _segmentProperties.SegmentSeparator = _structureEDI.SegmentSeparator;
                }

                if (_structureEDI.ElementGroupSeparator == char.MinValue)
                {
                    _structureEDI.ElementGroupSeparator = _segmentProperties.ElementGroupSeparator;
                }
                else if (_structureEDI.ElementGroupSeparator != _segmentProperties.ElementGroupSeparator)
                {
                    _segmentProperties.ElementGroupSeparator = _structureEDI.ElementGroupSeparator;
                }

                if (_structureEDI.ElementSeparator == char.MinValue)
                {
                    _structureEDI.ElementSeparator = _segmentProperties.ElementSeparator;
                }
                else if (_structureEDI.ElementSeparator != _segmentProperties.ElementSeparator)
                {
                    _segmentProperties.ElementSeparator = _structureEDI.ElementSeparator;
                }

                if (_structureEDI.ReleaseChar == char.MinValue)
                {
                    _structureEDI.ReleaseChar = _segmentProperties.ReleaseChar;
                }
                else if (_structureEDI.ReleaseChar != _segmentProperties.ReleaseChar)
                {
                    _segmentProperties.ReleaseChar = _structureEDI.ReleaseChar;
                }

                validateSeparator = false;
            }

            #endregion

            #region Hidden Elements

            foreach (XmlNode nElement in _handler.ConfigMap.GetHiddenOutputElements(node))
            {
                ElementOutput element = (ElementOutput)_handler.XOMLValidator.GetXOMLObject(new ElementOutput(), nElement, _handler);
                GetElementValue(element, nElement, section);
            }

            #endregion

            #region Segments

            Type type = Type.GetType(string.Format(OwlAdapterSettings.Settings.MapperEDILibrary, section.Name));
            if (type == null)
            {
                throw new OwlSectionException(string.Format(ETexts.GT(ErrorType.InvalidSegment), section.Name), node.OuterXml, node.Name, section.Name);
            }

            IEDISegment segment = (IEDISegment)Activator.CreateInstance(type);
            segment.Properties = _segmentProperties;

            #endregion

            if (segment != null)
            {
                string value = XOMLOutputValidator.GetEDISegment(segment, node, _handler, section, this).ToString();
                if (!value.IsNullOrWhiteSpace())
                {
                    _segmentCount++;
                    return(value);
                }
            }

            return(null);
        }