public override void GetElementValue(ElementOutput element, XmlNode node, SectionOutput section) { XmlElementOutput elementXml = (XmlElementOutput)element; if (!elementXml.ReleaseChars.HasValue) { elementXml.ReleaseChars = _structureXml.XmlReleaseChars; } base.GetElementValue(element, node, section); if (elementXml.ReleaseChars.Value) { element.Value = SecurityElement.Escape(element.Value); } }
public static IElement CreateElementFromDescriptor(ElementDescriptor elementDescriptor) { IElement element; if (elementDescriptor is ElementDescriptorChild) { element = new ElementChild(); } else if (elementDescriptor is ElementDescriptorInput) { element = new ElementInput(); } else if (elementDescriptor is ElementDescriptorButton) { element = new ElementButton(); } else if (elementDescriptor is ElementDescriptorOutput) { element = new ElementOutput(); } else if (elementDescriptor is ElementDescriptorInfo) { element = new ElementInfo(); } else if (elementDescriptor is ElementDescriptorMap) { element = new ElementMap(); } else if (elementDescriptor is ElementDescriptorBrowser) { element = new ElementBrowser(); } else { throw new Exception("Invalid descriptor"); } SetSharedAttributes(element, elementDescriptor); element.ElementDescriptor = elementDescriptor; return(element); }
protected override string GenerateSection(SectionOutput section, XmlNode node) { StringBuilder sb = new StringBuilder(); FlatFileSectionOutput sectionFlat = (FlatFileSectionOutput)section; bool hasElements = false; #region Obtener informacion de la seccion foreach (XmlNode nElement in _handler.ConfigMap.GetOutputElements(node)) { ElementOutput element = (ElementOutput)_handler.XOMLValidator.GetXOMLObject(new ElementOutput(), nElement, _handler); GetElementValue(element, nElement, section); if (!element.Hidden) { sb.Append(string.Concat(element.Value, sectionFlat.Separator)); hasElements = true; } } string resultValue = string.Empty; if (sectionFlat.RemoveFinalSeparators) { resultValue = sb.ToString().TrimEnd(sectionFlat.Separator.ToCharArray()); } else { resultValue = sb.ToString(); if (resultValue.Length > 0) { resultValue = resultValue.GetSafeSubstring(0, resultValue.Length - sectionFlat.Separator.Length); } } #endregion if (hasElements) { _segmentCount++; return(resultValue); } return(null); // If all elements are (Oculto="Si") }
public override void GetElementValue(ElementOutput element, XmlNode node, SectionOutput section) { base.GetElementValue(element, node, section); element.Value = element.Value.Replace("\"", "\\\"").Replace("\\", "\\\\"); }
protected override string GenerateSection(SectionOutput section, XmlNode node) { StringBuilder sb = new StringBuilder(); JsonSectionOutput sectionJson = (JsonSectionOutput)section; #region Obtener informacion de la seccion bool addSeparator = false; foreach (XmlNode nElement in _handler.ConfigMap.GetOutputElements(node)) { ElementOutput element = (ElementOutput)_handler.XOMLValidator.GetXOMLObject(new ElementOutput(), nElement, _handler); GetElementValue(element, nElement, section); if (!element.Hidden) { if (addSeparator) { sb.Append(","); } if (element.DataType == ElementDataType.Numeric) { sb.Append($"\"{element.Name}\":{element.Value}"); } else { sb.Append($"\"{element.Name}\":\"{element.Value}\""); } addSeparator = true; } } #endregion if (section.Repetitions > 1 || !section.Itera.IsNullOrWhiteSpace() || sectionJson.JsonArray) { if (section.Consecutive > 1) { sb.Insert(0, ",{"); } else { sb.Insert(0, "{"); } if (section.Consecutive == 1) { sb.Insert(0, $"\"{section.Name}\":["); if (node.PreviousSibling != null && (node.PreviousSibling.Name == "element" || node.PreviousSibling.Name == "section")) { sb.Insert(0, ","); } } } else { sb.Insert(0, $"\"{section.Name}\":{{"); if (node.PreviousSibling != null && (node.PreviousSibling.Name == "element" || node.PreviousSibling.Name == "section")) { sb.Insert(0, ","); } } _segmentCount++; return(sb.ToString()); }
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); }