Example #1
0
        /// <summary>
        /// Map WebOps Entity to UPS Entity
        /// </summary>
        /// <param name="webopsObj">Webops Entity</param>
        public static void MapWebopsToSPLUS(WebOpsEntity webopsObj)
        {
            Mapper.CreateMap <WebOpsEntity, OrderProcessingInstructions>()
            .ForMember(ordprs => ordprs.customerOrderNumber, opt => opt.MapFrom(src => src.invoice_Number))
            .ForMember(ordprs => ordprs.inventoryOrder, opt => opt.MapFrom(src => src.invertoryOrder))
            .ForMember(ordprs => ordprs.timeSentInGMT, opt => opt.MapFrom(src => src.timeSentInGMT));

            Mapper.CreateMap <WebOpsEntity, Authorizer>()
            .ForMember(aut => aut.firstName, opt => opt.MapFrom(src => src.firstName))
            .ForMember(aut => aut.lastName, opt => opt.MapFrom(src => src.lastName));
            //Map to destination Entity
            OrderProcessingInstructions ordprc = Mapper.Map <WebOpsEntity, OrderProcessingInstructions>(webopsObj);
            //Map to destination Entity
            Authorizer           auth   = Mapper.Map <WebOpsEntity, Authorizer>(webopsObj);
            OrderCreationRequest ordcrt = new OrderCreationRequest();

            ordcrt.orderProcessing = ordprc;
            ordcrt.authorize       = auth;
            Header header1 = new Header();

            header1.messageConsumer   = "SplusAdapter";
            header1.messageFunction   = "OrderCreationRequest";
            header1.messageIdentifier = "test-1000830107";
            header1.messageProducer   = "SIP";
            header1.processIdentifier = "897537096";
            header1.messageDateTime   = DateTime.Now;
            Upsscs ups = new Upsscs();

            ups.applicationVersion = "1.0";
            ups.schemaVersion      = "5.1";
            ups.header             = header1;
            ups.oderCreation       = ordcrt;
            //Call method to convert to xml
            ConvertToUPSXML.ConvertToXML(ups);
        }
Example #2
0
        public static void ConvertToXML(Upsscs ups)
        {
            XmlWriterSettings setting = new XmlWriterSettings();

            //setting.Encoding = new UnicodeEncoding(false, false);
            setting.Encoding           = Encoding.UTF8;
            setting.OmitXmlDeclaration = false;
            //Represents an XML document,
            XmlDocument    xmlDoc = new XmlDocument();
            XmlDeclaration xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "yes");
            // Initializes a new instance of the XmlDocument class.
            XmlSerializer xmlSerializer = new XmlSerializer(ups.GetType());

            using (MemoryStream xmlStream = new MemoryStream())
            {
                xmlSerializer.Serialize(xmlStream, ups);
                xmlStream.Position = 0;
                //Loads the XML document from the specified string.
                xmlDoc.Load(xmlStream);
                //Call Validate Method
                ValidateUPSXML.ValidateXML(xmlDoc.InnerXml, ups.oderCreation.orderProcessing.customerOrderNumber);
            }
        }