コード例 #1
0
        public string GetRating(string productID)
        {
            if (string.IsNullOrEmpty(productID))
            {
                return(string.Empty);
            }
            else
            {
                AlatestType = DivType.Rating;
                productID   = productID.Replace(" ", "");
            }

            string url = string.Concat(AlatestServerUrl, AlatestVirtualDirUrl, ReviewPartnerID,
                                       productID.EndsWith("/") ? productID : string.Concat(productID, "/"));

            if (!string.IsNullOrEmpty(url))
            {
                using (var stream = new StreamReader(WebRequest.Create(url).GetResponse().GetResponseStream()))
                {
                    string value = stream.ReadToEnd();

                    if (!string.IsNullOrEmpty(value))
                    {
                        if (Alatest.SaveRating(new AlatestRating {
                            ProductID = productID, Review = value
                        }))
                        {
                            return(Alatest.GetRatingFromDatabase(productID));
                        }
                    }
                }
            }

            return(string.Empty);
        }
コード例 #2
0
        public string GetReview(string productID)
        {
            try
            {
                if (string.IsNullOrEmpty(productID))
                {
                    return(string.Empty);
                }
                else
                {
                    AlatestType = DivType.Review;
                    productID   = productID.Replace(" ", "");
                }

                string url = string.Concat(AlatestServerUrl, AlatestVirtualDirUrl, ReviewPartnerID,
                                           productID.EndsWith("/") ? productID : string.Concat(productID, "/"),
                                           MinimumReviews);

                if (!string.IsNullOrEmpty(url))
                {
                    using (var stream = new StreamReader(WebRequest.Create(url).GetResponse().GetResponseStream()))
                    {
                        string value = stream.ReadToEnd();

                        if (!string.IsNullOrEmpty(value))
                        {
                            if (Alatest.SaveReview(new AlatestReview {
                                ProductID = productID, Review = value
                            }))
                            {
                                return(Alatest.GetReviewFromDatabase(productID));
                            }
                        }
                    }
                }

                return(string.Empty);
            }
            catch (Exception ex)
            {
                log.Error(string.Format("AlatestService.GetReview(): Failed! \r\n{0}"), ex);
                return(string.Empty);
            }
        }