コード例 #1
0
        public ProductReturn GetProductsWithPrice(string customerNumber, ProductLine[] products, DateTime effDate,
                                                  bool getAllFields)
        {
            if (header == null)
            {
                header = LoadHeader(unknownHeaders[0]);
            }

            ProductReturn retVal = new ProductReturn();

            IUserProfileLogic profileLogic       = _scope.GetService(typeof(IUserProfileLogic)) as IUserProfileLogic;
            UserProfileReturn profileLogicReturn = profileLogic.GetUserProfile(header.UserName, false);

            if (profileLogicReturn.UserProfiles.Count > 0)
            {
                UserProfile profile = profileLogicReturn.UserProfiles[0];

                PagedResults <Customer> customers = profileLogic.CustomerSearch(profile, customerNumber, new Core.Models.Paging.PagingModel(), string.Empty, CustomerSearchType.Customer);

                if (customers.TotalResults > 0)
                {
                    retVal.Products.AddRange(GetItemPricing(customers.Results[0].CustomerBranch, customerNumber, products, effDate));
                }
            }

            return(retVal);
        }
コード例 #2
0
        private AuthHeader LoadHeader(SoapUnknownHeader authHeader)
        {
            AuthHeader header = new AuthHeader();

            header.UserName = authHeader.Element.ChildNodes[1].InnerText;
            header.Password = authHeader.Element.ChildNodes[3].InnerText;

            return(header);
        }
コード例 #3
0
        /// <summary>
        /// main method for handling requests send to this handler
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            // get data
            string xml = new StreamReader(context.Request.InputStream).ReadToEnd();

            XDocument  doc = XDocument.Load(new StringReader(xml));
            XNamespace xns = XNamespace.Get("http://schemas.xmlsoap.org/soap/envelope/");

            AuthHeader     header = GetSoapHeader(doc.Descendants(xns + "Header").First().FirstNode);
            PricingRequest body   = GetSoapBody(doc.Descendants(xns + "Body").First().FirstNode);

            // process pricing
            ProductReturn returnedPrices = new ProductReturn();

            IUserProfileLogic profileLogic       = _scope.GetService(typeof(IUserProfileLogic)) as IUserProfileLogic;
            UserProfileReturn profileLogicReturn = profileLogic.GetUserProfile(header.UserName, false);

            if (profileLogicReturn.UserProfiles.Count > 0)
            {
                UserProfile profile = profileLogicReturn.UserProfiles[0];

                PagedResults <Customer> customers = profileLogic.CustomerSearch(profile, body.customerNumber, new Core.Models.Paging.PagingModel(), string.Empty, CustomerSearchType.Customer);

                if (customers.TotalResults > 0)
                {
                    returnedPrices.Products.AddRange(GetItemPricing(customers.Results[0].CustomerBranch, body.customerNumber, body.products, ConvertEffectiveDate(body.effDate)));
                }
            }


            // return results

            SoapEnvelope soap = new SoapEnvelope();

            soap.Body.Response.Results = GetProductString(returnedPrices);

            XmlSerializer serializer = new XmlSerializer(soap.GetType());

            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();

            namespaces.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            namespaces.Add("xsd", "http://www.w3.org/2001/XMLSchema");
            namespaces.Add("soap", "http://schemas.xmlsoap.org/soap/envelope/");

            serializer.Serialize(context.Response.OutputStream, soap, namespaces);

            context.Response.ContentType = "text/xml";
        }