Пример #1
0
 private void GetItemRssFeedContents(AspxCommonInfo aspxCommonObj, XmlTextWriter rssXml, string pageURL, int count)
 {
     try
     {
         string             noImageUrl = string.Empty;
         StoreSettingConfig ssc        = new StoreSettingConfig();
         noImageUrl = ssc.GetStoreSettingsByKey(StoreSetting.DefaultProductImageURL, aspxCommonObj.StoreID,
                                                aspxCommonObj.PortalID, aspxCommonObj.CultureName);
         string[] path                 = pageURL.Split('?');
         string   pagepath             = path[0];
         string   x                    = HttpContext.Current.Request.ApplicationPath;
         string   authority            = HttpContext.Current.Request.Url.Authority;
         string   pageUrl              = authority + x;
         ServiceItemController sic     = new ServiceItemController();
         List <ServiceItemRss> itemRss = sic.GetServiceTypeRssFeedContent(aspxCommonObj, count);
         if (itemRss.Count > 0)
         {
             foreach (ServiceItemRss rssItemData in itemRss)
             {
                 string imagePath = "Modules/AspxCommerce/AspxItemsManagement/uploads/" + rssItemData.ImagePath;
                 if (rssItemData.ImagePath != "")
                 {
                     //Resize Image Dynamically
                     InterceptImageController.ImageBuilder(rssItemData.ImagePath, ImageType.Small, ImageCategoryType.Item, aspxCommonObj);
                 }
                 rssXml.WriteStartElement("item");
                 rssXml.WriteElementString("title", rssItemData.ServiceName);
                 rssXml.WriteElementString("link",
                                           "http://" + pageUrl + "/service/" + rssItemData.ServiceName +
                                           SageFrameSettingKeys.PageExtension);
                 rssXml.WriteStartElement("description");
                 var description = "";
                 if (rssItemData.ImagePath == "")
                 {
                     imagePath = noImageUrl;
                 }
                 description = "<div><a href=http://" + pageUrl + "/service/" + rssItemData.ServiceName +
                               SageFrameSettingKeys.PageExtension + "><img src=http://" + pageUrl + "/" +
                               imagePath.Replace("uploads", "uploads/Small") + " alt=" + rssItemData.ServiceName + " /> </a></div>";
                 description += "</br>" + HttpUtility.HtmlDecode(rssItemData.ShortDescription);
                 rssXml.WriteCData(description);
                 rssXml.WriteEndElement();
                 rssXml.WriteElementString("pubDate", rssItemData.AddedOn);
                 rssXml.WriteEndElement();
             }
         }
         else
         {
             rssXml.WriteStartElement("item");
             rssXml.WriteElementString("title", "");
             rssXml.WriteElementString("link", "");
             rssXml.WriteStartElement("description");
             var description = "";
             description = "<div><h2><span>This store has no items listed yet!</span></h2></div>";
             rssXml.WriteCData(description);
             rssXml.WriteEndElement();
             rssXml.WriteEndElement();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }