コード例 #1
0
        public void Send(ESAPrescription prescription)
        {
            var ordernumber = prescription.EsaPatientDetail.Patient.PatientId.ReferenceNumber;

            using (var wb = new WebClient())
            {
                try
                {
                    var xml = _serializer.Serialize(prescription);
                    // _logger.Information("Sending XML ESA - {OrderNumber} {xml}", ordernumber, xml);
                    //xml = "<ESAPrescription><MessageID>11cd251c-0399-403d-bd33-7290021c3bbb</MessageID><Version>V1.0</Version><Date>171113110024</Date><SenderID>42</SenderID><AccountID>1</AccountID><PatientDetail><Patient><PatientId><ReferenceNumber>13131835</ReferenceNumber></PatientId><PatientName><FirstName>Simon</FirstName><Surname>Powell</Surname><MiddleName /><Title>Mr.</Title></PatientName><DOB>05/09/1972</DOB><Sex>1</Sex><HomeAddress><CountryCode>GB</CountryCode><PostCode>DY8 1BY</PostCode><AddressLine1>19 Park Street</AddressLine1><AddressLine2>Stourbridge</AddressLine2><AddressLine3>West Midlands</AddressLine3></HomeAddress><SaturdayDelivery>N</SaturdayDelivery><DeliveryAddress><CountryCode>GB</CountryCode><PostCode>DY8 1BY</PostCode><AddressLine1>19 Park Street</AddressLine1><AddressLine2>Stourbridge</AddressLine2><AddressLine3>West Midlands</AddressLine3></DeliveryAddress><UPSAccessPointDelivery>N</UPSAccessPointDelivery><Notes /><Telephone>07910123999</Telephone><Mobile>07910123999</Mobile><Email>[email protected]</Email></Patient><FamilyDoctor><Organisation /><Title /><FirstName /><MiddleName /><Surname /><AddressLine1 /><AddressLine2 /><AddressLine3 /><AddressLine4 /><PostCode /><CountryCode /></FamilyDoctor></PatientDetail><Prescription><Guid>5a06fe93c85a80c6981412f9</Guid><Repeats>0</Repeats><Prescriber><Doctor><GMCNO>6162948</GMCNO><DoctorName>Dr Khalid Efleih Hassan</DoctorName></Doctor></Prescriber><Product><Guid>888282112</Guid><ProductCode>8882821</ProductCode><Description>Sildenafil 25mg</Description><ProductQuantity><Quantity>1</Quantity><Units>Tablets</Units><Dosage>12</Dosage></ProductQuantity><Instructions>Take one tablet 1 hour before sexual activity. Do not take more than one tablet per day. Do not use any other type of medication for erectile dysfunction within 72 hours of taking sildenafil.</Instructions><Instructions2 /></Product><Questionnaire><Question>Do you need help completing this questionnaire?</Question><Answer>No</Answer><Question>Are you:</Question><Answer>Male</Answer><Question>Are you pregnant, breastfeeding or trying to get pregnant?</Question><Answer /><Question>Date of birth:</Question><Answer>6,9,1972</Answer><Question>Would you prefer a male or female doctor to review your answers?</Question><Answer>I don't mind</Answer><Question>Height (in feet and inches or metres and centimetres):</Question><Answer>ft,6,3</Answer><Question>Weight (in stones or kilograms):</Question><Answer>st,18,2</Answer><Question>Have you had your blood pressure checked in the last 6 months?</Question><Answer>Yes</Answer><Question>Is your blood pressure:</Question><Answer>Normal</Answer><Question>Do you know your exact blood pressure?</Question><Answer>No</Answer><Question>Tick the appropriate boxes to show whether you have, or have ever been diagnosed with, any of the following.</Question><Answer /><Question>Do you currently take any other medication (prescribed or bought over the counter)?</Question><Answer>0</Answer><Question>Are you allergic to any foods or drugs?</Question><Answer>No</Answer><Question>Have you ever had any major surgery?</Question><Answer>0</Answer><Question>Do you have a family history of any medical problems?</Question><Answer>0</Answer><Question>Do you drink alcohol or smoke?</Question><Answer>Yes</Answer><Question>Do you take, or intend to take, any recreational drugs during or before sexual activity?</Question><Answer>No</Answer><Question>Do you have persistent problems getting or keeping an erection when sexually aroused?</Question><Answer>Yes</Answer><Question>Have you seen a doctor or nurse about your erectile dysfunction?</Question><Answer>No</Answer><Question>Have you used [ProductName] before?</Question><Answer>What dose were you given?</Answer><Question>What treatment(s) have you tried?</Question><Answer>Which dose did you take?</Answer><Question>Please explain why you want to order [ProductName].</Question><Answer>Since you haven't taken treatment for erectile dysfunction before, we need to ask you a few extra questions and give you some important information.</Answer><Question>True</Question><Answer>Because erectile dysfunction treatments can lower blood pressure, we need to ask you some detailed questions about your heart and circulation.</Answer><Question>No</Question><Answer>Have you ever experienced tightness or heaviness in the chest with a feeling of breathlessness?</Answer><Question>No</Question><Answer>Have you ever had to stop any exercise or strenuous activity because you feel too breathless or become clammy or sweaty?</Answer><Question>No</Question><Answer>Have you ever been prescribed a ‘nitrate’ medication for angina or heart disease, such as GTN (glyceryl tri-nitrate) spray, tablets or other type of nitrate medication?</Answer><Question>No</Question><Answer>Erectile dysfunction treatments can cause a fatal interaction with medicines from the \"nitrates\" family used to help with angina or heart disease. If you are ever prescribed a GTN (glyceryl tri-nitrate) spray, tablets or other type of nitrate medication, you must NOT take erectile dysfunction treatments. </Answer><Question>True</Question><Answer>Do you ever experience dizziness or lightheadedness immediately after standing up?</Answer><Question>No</Question><Answer>Some men with erectile dysfunction may be tempted try \"herbal\" remedies to help with their symptoms. However, many herbal remedies contain prescription only medicines and are sold by unregulated manufacturers. Taking them, particularly at the same time as prescription erectile dysfunction treatments, can often be very dangerous. You must therefore NOT take any herbal treatments whilst taking erectile dysfunction treatments.</Answer><Question>True</Question><Answer>Are your erections sometimes fine (for example, first thing in the morning or when watching pornography)?</Answer><Question>No</Question><Answer>Are you currently having any emotional or psychological problems?</Answer><Question>No</Question><Answer>Has a doctor advised you to avoid strenuous exercise?</Answer><Question>No</Question><Answer>Do you need to urinate frequently or have any problems urinating?</Answer><Question>No</Question><Answer>Do you consider yourself to have a disability?</Answer><Question>No</Question><Answer>Is there anything else you would like to mention to the doctor or which you think might be relevant?</Answer><Question>No</Question><Answer>Have you read the patient information leaflet for [ProductName] and understood:</Answer><Question>Yes</Question><Answer>We recommend that you tell your GP about any medication you buy through our site.</Answer><Question>No</Question></Questionnaire><ccCheck><ccNumber /></ccCheck></Prescription></ESAPrescription>";
                    var response   = wb.UploadString(_url, xml);
                    var reponsexml = _serializer.Serialize(response);

                    // if (!response.Contains("Success"))
                    //_logger.Information("Failed XML ESA - {OrderNumber} {Response}", ordernumber, reponsexml);
                    // else
                    //_logger.Information("Success XML ESA - {OrderNumber}", ordernumber);
                }
                catch (Exception ex)
                {
                    //_logger.Error("Esa Error {error}", ex.Message);
                }
            }
        }
コード例 #2
0
        public void Product_Serialize()
        {
            // Arrange
            Guid randomName = Guid.NewGuid();

            Product newProduct = new Product()
            {
                name           = randomName.ToString(),
                price_in_cents = 100,
                interval_unit  = IntervalUnit.month,
                interval       = 1
            };

            // Act
            string msg        = string.Empty;
            var    serializer = new DotNetXmlSerializer();

            msg = serializer.Serialize(newProduct);

            // Assert
            XDocument doc                 = XDocument.Parse(msg);
            XElement  nameElement         = doc.Root.Elements().FirstOrDefault(e => e.Name == "name");
            XElement  priceElement        = doc.Root.Elements().FirstOrDefault(e => e.Name == "price_in_cents");
            XElement  intervalUnitElement = doc.Root.Elements().FirstOrDefault(e => e.Name == "interval_unit");
            XElement  intervalElement     = doc.Root.Elements().FirstOrDefault(e => e.Name == "interval");

            Assert.IsTrue(doc.Root.Elements().Count() == 4);
            Assert.IsFalse(string.IsNullOrEmpty(nameElement.Value));
            Assert.IsTrue(randomName.ToString() == nameElement.Value);
            Assert.IsNotNull(priceElement);
            Assert.IsTrue(int.Parse(priceElement.Value) > int.MinValue);
            Assert.AreEqual((int)newProduct.price_in_cents, int.Parse(priceElement.Value));
            Assert.IsFalse(string.IsNullOrEmpty(intervalUnitElement.Value));
            Assert.IsTrue((int)newProduct.interval_unit == (int)Enum.Parse(typeof(IntervalUnit), intervalUnitElement.Value));
        }
        public void SerializePingRequestTest()
        {
            PingRequest request = new PingRequest();

            request.Language = Language.en;
            request.Merchant = new Merchant()
            {
                ApiKey   = base.apiKey,
                ApiLogin = base.apiLogin
            };
            request.Url = base.paymentsUrl;

            request.Command = Command.PING;

            DotNetXmlSerializer serializer = new DotNetXmlSerializer();

            string serializedObject = serializer.Serialize(request);

            Assert.IsTrue(serializedObject.Contains("<request>"));
            Assert.IsTrue(serializedObject.Contains("<command>PING</command>"));
            Assert.IsTrue(serializedObject.Contains("<apiLogin>012345678901</apiLogin>"));
            Assert.IsTrue(serializedObject.Contains("<apiKey>012345678901</apiKey>"));
            Assert.IsTrue(serializedObject.Contains("<language>en</language>"));
            Assert.IsTrue(serializedObject.Contains("</request>"));
        }
コード例 #4
0
ファイル: FileHelper.cs プロジェクト: hsudas/flexi
        public string WriteAllText(string rootElement, Object requestObject, string fullPath)
        {
            DotNetXmlSerializer serializer = new DotNetXmlSerializer();
            string xmlRequest = serializer.Serialize(requestObject);

            File.WriteAllText(fullPath, xmlRequest);
            return(xmlRequest);
        }
コード例 #5
0
        /// <summary>
        ///     Adds an object as serialized xml string.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="request">The request.</param>
        /// <param name="obj">The object that will be serialized and added as xml string content.</param>
        /// <param name="name">A name needed when content is a MultipartFormDataContent already.</param>
        /// <param name="fileName">A file name needed when content is a MultipartFormDataContent already.</param>
        /// <returns>
        ///     this.
        /// </returns>
        /// <remarks>
        ///     Throws exception if the given object is null, or if the
        ///     serialized xml string is null or empty.
        /// </remarks>
        public static T AddXml <T>(this T request, object obj, string name = "", string fileName = "")
            where T : RestRequest
        {
            obj.ThrowIfNull(nameof(obj));
            var serializer = new DotNetXmlSerializer();
            var xmlContent = serializer.Serialize(obj);

            xmlContent.ThrowIfNullOrEmpty("BaseRestRequest", "xmlContent");
            // .net default encoding is UTF-8
            if (!IsNullOrEmpty(xmlContent))
            {
                request.AddContent(new StringContent(xmlContent, Encoding.UTF8, serializer.ContentType), name, fileName);
            }
            return(request);
        }
        public void SerializePaymentRequestTest()
        {
            PaymentRequest request = new PaymentRequest();

            request.Language = Language.en;
            request.Merchant = new Merchant()
            {
                ApiKey   = base.apiKey,
                ApiLogin = base.apiLogin
            };
            request.Url = base.paymentsUrl;

            request.Command = Command.SUBMIT_TRANSACTION;

            request.Transaction                             = new Transaction();
            request.Transaction.Order                       = new Order();
            request.Transaction.Order.AccountId             = 8;
            request.Transaction.Order.ReferenceCode         = "A1B2C3";
            request.Transaction.Order.Description           = "ALL IN 5";
            request.Transaction.Order.Language              = request.Language;
            request.Transaction.Order.Signature             = "575522081b12448a6a0cf326716a9c13";
            request.Transaction.Order.Buyer                 = new Buyer();
            request.Transaction.Order.Buyer.FullName        = "NAME 1383885401927";
            request.Transaction.Order.Buyer.Address         = new Address();
            request.Transaction.Order.Buyer.Address.Street1 = "1";
            request.Transaction.Order.Buyer.Address.City    = "Bogotá";
            request.Transaction.Order.AdditionalValues      = new SerializableDictionary <string, AdditionalValue>();
            request.Transaction.Order.AdditionalValues.Add("TX_TAX_RETURN_BASE", new AdditionalValue()
            {
                Currency = Currency.USD,
                Value    = 100.00M
            });
            request.Transaction.Order.AdditionalValues.Add("TX_VALUE", new AdditionalValue()
            {
                Currency = Currency.USD,
                Value    = 100.00M
            });
            request.Transaction.Order.AdditionalValues.Add("TX_TAX", new AdditionalValue()
            {
                Currency = Currency.USD,
                Value    = 16.00M
            });
            request.Transaction.CreditCard                = new CreditCard();
            request.Transaction.CreditCard.Name           = "NAME 1383922917718";
            request.Transaction.CreditCard.Number         = "4005580000029205";
            request.Transaction.CreditCard.SecurityCode   = "495";
            request.Transaction.CreditCard.ExpirationDate = "2015/01";
            request.Transaction.TransactionType           = TransactionType.AUTHORIZATION;
            request.Transaction.PaymentMethod             = PaymentMethod.VISA;
            request.Transaction.Source                = TransactionSource.PAYU_SDK;
            request.Transaction.PaymentCountry        = PaymentCountry.PA;
            request.Transaction.Payer                 = new Payer();
            request.Transaction.Payer.FullName        = "NAME 1383922917718";
            request.Transaction.Payer.Address         = new Address();
            request.Transaction.Payer.Address.City    = "Bogotá";
            request.Transaction.Payer.Address.Street1 = "ABC 123";
            request.Transaction.IpAddress             = "127.0.0.1";
            request.Transaction.Cookie                = "Cookie";
            request.Transaction.UserAgent             = ".NET te quiero como a Dominique de DM Argentina, eres lo máximo";
            request.Transaction.ExtraParameters       = new SerializableDictionary <string, string>();
            request.Transaction.ExtraParameters.Add("INSTALLMENTS_NUMBER", "3");

            DotNetXmlSerializer serializer = new DotNetXmlSerializer();
            string serializedObject        = serializer.Serialize(request);

            Assert.IsTrue(serializedObject.Contains("<request>"));
            Assert.IsTrue(serializedObject.Contains("<command>SUBMIT_TRANSACTION</command>"));
            Assert.IsTrue(serializedObject.Contains("<language>en</language>"));
            Assert.IsTrue(serializedObject.Contains("<merchant>"));
            Assert.IsTrue(serializedObject.Contains("<apiLogin>012345678901</apiLogin>"));
            Assert.IsTrue(serializedObject.Contains("<apiKey>012345678901</apiKey>"));
            Assert.IsTrue(serializedObject.Contains("</merchant>"));
            Assert.IsTrue(serializedObject.Contains("<transaction>"));
            Assert.IsTrue(serializedObject.Contains("<order>"));
            Assert.IsTrue(serializedObject.Contains("<accountId>8</accountId>"));
            Assert.IsTrue(serializedObject.Contains("<referenceCode>A1B2C3</referenceCode>"));
            Assert.IsTrue(serializedObject.Contains("<description>ALL IN 5</description>"));
            Assert.IsTrue(serializedObject.Contains("<language>en</language>"));
            Assert.IsTrue(serializedObject.Contains("<signature>575522081b12448a6a0cf326716a9c13</signature>"));
            Assert.IsTrue(serializedObject.Contains("<buyer>"));
            Assert.IsTrue(serializedObject.Contains("<fullName>NAME 1383885401927</fullName>"));
            Assert.IsTrue(serializedObject.Contains("<shippingAddress>"));
            Assert.IsTrue(serializedObject.Contains("<street1>1</street1>"));
            Assert.IsTrue(serializedObject.Contains("<city>Bogotá</city>"));
            Assert.IsTrue(serializedObject.Contains("</shippingAddress>"));
            Assert.IsTrue(serializedObject.Contains("</buyer>"));
            Assert.IsTrue(serializedObject.Contains("<additionalValues>"));
            Assert.IsTrue(serializedObject.Contains("<entry>"));
            Assert.IsTrue(serializedObject.Contains("<string>TX_TAX_RETURN_BASE</string>"));
            Assert.IsTrue(serializedObject.Contains("<additionalValue>"));
            Assert.IsTrue(serializedObject.Contains("<value>100.00</value>"));
            Assert.IsTrue(serializedObject.Contains("<currency>USD</currency>"));
            Assert.IsTrue(serializedObject.Contains("</additionalValue>"));
            Assert.IsTrue(serializedObject.Contains("</entry>"));
            Assert.IsTrue(serializedObject.Contains("</additionalValues>"));
            Assert.IsTrue(serializedObject.Contains("</order>"));
            Assert.IsTrue(serializedObject.Contains("<creditCard>"));
            Assert.IsTrue(serializedObject.Contains("<number>4005580000029205</number>"));
            Assert.IsTrue(serializedObject.Contains("<securityCode>495</securityCode>"));
            Assert.IsTrue(serializedObject.Contains("<expirationDate>2015/01</expirationDate>"));
            Assert.IsTrue(serializedObject.Contains("<name>NAME 1383922917718</name>"));
            Assert.IsTrue(serializedObject.Contains("</creditCard>"));
            Assert.IsTrue(serializedObject.Contains("<type>AUTHORIZATION</type>"));
            Assert.IsTrue(serializedObject.Contains("<paymentMethod>VISA</paymentMethod>"));
            Assert.IsTrue(serializedObject.Contains("<source>PAYU_SDK</source>"));
            Assert.IsTrue(serializedObject.Contains("<paymentCountry>PA</paymentCountry>"));
            Assert.IsTrue(serializedObject.Contains("<payer>"));
            Assert.IsTrue(serializedObject.Contains("<fullName>NAME 1383922917718</fullName>"));
            Assert.IsTrue(serializedObject.Contains("<billingAddress>"));
            Assert.IsTrue(serializedObject.Contains("<street1>ABC 123</street1>"));
            Assert.IsTrue(serializedObject.Contains("<city>Bogotá</city>"));
            Assert.IsTrue(serializedObject.Contains("</billingAddress>"));
            Assert.IsTrue(serializedObject.Contains("</payer>"));
            Assert.IsTrue(serializedObject.Contains("<ipAddress>127.0.0.1</ipAddress>"));
            Assert.IsTrue(serializedObject.Contains("<cookie>Cookie</cookie>"));
            Assert.IsTrue(serializedObject.Contains("<extraParameters>"));
            Assert.IsTrue(serializedObject.Contains("<entry>"));
            Assert.IsTrue(serializedObject.Contains("<string>INSTALLMENTS_NUMBER</string>"));
            Assert.IsTrue(serializedObject.Contains("<string>3</string>"));
            Assert.IsTrue(serializedObject.Contains("</entry>"));
            Assert.IsTrue(serializedObject.Contains("</extraParameters>"));
            Assert.IsTrue(serializedObject.Contains("</transaction>"));
            Assert.IsTrue(serializedObject.Contains("</request>"));
        }