Example #1
0
        public XElement ParseToXmlElement(DestinationMetadata metadata)
        {
            XElement element = new XElement("MetaData");

            element.Add(new XElement("Dest", metadata.Destination));
            if (metadata.GenerateDate.HasValue)
            {
                element.Add(new XElement("GenerateDate", metadata.GenerateDate));
            }
            if (!string.IsNullOrEmpty(metadata.InsertMethodName))
            {
                element.Add(new XElement("InsertMethodName", metadata.InsertMethodName));
            }
            element.Add(new XElement("Source", metadata.Source));
            element.Add(new XElement("PackageId", metadata.CorrelationId));
            element.Add(new XElement("BussinesId", metadata.BussinesId));

            return(element);
        }
Example #2
0
        //public XElement ParseToXmlElement(Metadata metadata)
        //{
        //    XElement element = new XElement("MetaData");
        //    element.Add(new XElement("Dest", string.Join(";", metadata.Destinations)));
        //    if(metadata.GenerateDate.HasValue)
        //        element.Add(new XElement("GenerateDate", metadata.GenerateDate));
        //    if(metadata.CorrelationId!=Guid.Empty)
        //        element.Add(new XElement("CorrelationId"));
        //    if(metadata.AttachmentId)
        //    if(!string.IsNullOrEmpty(metadata.Source))
        //        element.Add(new XElement("Source", metadata.Source));
        //    if(!Guid.Empty.Equals(metadata.CorrelationId))
        //        element.Add(new XElement("PackageId", metadata.CorrelationId));

        //    return element;
        //}

        public DestinationMetadata ParseFromXElementToDestinationMetadata(XElement message)
        {
            if (message == null || message.IsEmpty)
            {
                throw new EmptyMetdaDataXmlProvieded();
            }
            if (message.Name.LocalName.ToUpper() != "DESTMETADATA")
            {
                throw new DiffrentThenMetadataNodeWasProvidedFound(message);
            }

            DestinationMetadata metaData = new DestinationMetadata();

            metaData.Destination      = message.Element("Dest").Value;
            metaData.GenerateDate     = ParseDate(message.Element("GenerateDate"));
            metaData.InsertMethodName = ParseString(message.Element("InsertMethodName"));
            metaData.Source           = message.Element("Source")?.Value;
            metaData.CorrelationId    = Guid.Parse(message.Element("PackageId").Value);
            metaData.BussinesId       = message.Element("BussinesId").Value;

            return(metaData);
        }