private static SiteMapData GetSiteMapDataFromReader(SqlDataReader reader) { var prefUrl = SettingsMain.SiteUrl; prefUrl = prefUrl.Contains("http://") ? prefUrl : "http://" + prefUrl; var siteMapData = new SiteMapData { Changefreq = DefaultChangeFreq, Priority = DefaultPriority }; if (reader.FieldCount == 1) { siteMapData.Loc = prefUrl + UrlService.GetLink(ParamType.Category, SQLDataHelper.GetString(reader, "UrlPath"), SQLDataHelper.GetInt(reader, "CategoryId")); siteMapData.Lastmod = DateTime.Now; } else if (reader.GetName(0).ToLower() == "productid") { siteMapData.Loc = prefUrl + UrlService.GetLink(ParamType.Product, SQLDataHelper.GetString(reader, "UrlPath"), SQLDataHelper.GetInt(reader, "Productid")); siteMapData.Lastmod = SQLDataHelper.GetDateTime(reader, "DateModified"); } else if (reader.GetName(0).ToLower() == "newsid") { siteMapData.Loc = prefUrl + UrlService.GetLink(ParamType.News, SQLDataHelper.GetString(reader, "UrlPath"), SQLDataHelper.GetInt(reader, "NewsID")); siteMapData.Lastmod = SQLDataHelper.GetDateTime(reader, "AddingDate"); } else if (reader.GetName(0).ToLower() == "staticpageid") { siteMapData.Loc = prefUrl + UrlService.GetLink(ParamType.StaticPage, SQLDataHelper.GetString(reader, "UrlPath"), SQLDataHelper.GetInt(reader, "StaticPageID")); siteMapData.Lastmod = SQLDataHelper.GetDateTime(reader, "ModifyDate"); } return(siteMapData); }
/// <summary> /// return data from reader /// </summary> /// <param name="reader"></param> /// <returns></returns> private static SiteMapData GetSiteMapDataFromReader(SqlDataReader reader) { var prefUrl = SettingsMain.SiteUrl + "/"; var siteMapData = new SiteMapData { Changefreq = DefaultChangeFreq, Priority = DefaultPriority }; if (reader.GetName(0).ToLower() == "categoryid") { siteMapData.Loc = prefUrl + UrlService.GetLink(ParamType.Category, SQLDataHelper.GetString(reader, "UrlPath"), SQLDataHelper.GetInt(reader, "CategoryId")); siteMapData.Lastmod = DateTime.Now; } else if (reader.GetName(0).ToLower() == "productid") { siteMapData.Loc = prefUrl + UrlService.GetLink(ParamType.Product, SQLDataHelper.GetString(reader, "UrlPath"), SQLDataHelper.GetInt(reader, "Productid")); siteMapData.Lastmod = SQLDataHelper.GetDateTime(reader, "DateModified"); } else if (reader.GetName(0).ToLower() == "newsid") { siteMapData.Loc = prefUrl + UrlService.GetLink(ParamType.News, SQLDataHelper.GetString(reader, "UrlPath"), SQLDataHelper.GetInt(reader, "NewsID")); siteMapData.Lastmod = SQLDataHelper.GetDateTime(reader, "AddingDate"); } else if (reader.GetName(0).ToLower() == "staticpageid") { siteMapData.Loc = prefUrl + UrlService.GetLink(ParamType.StaticPage, SQLDataHelper.GetString(reader, "UrlPath"), SQLDataHelper.GetInt(reader, "StaticPageID")); siteMapData.Lastmod = SQLDataHelper.GetDateTime(reader, "ModifyDate"); } else if (reader.GetName(0).ToLower() == "brandid") { siteMapData.Loc = prefUrl + UrlService.GetLink(ParamType.Brand, SQLDataHelper.GetString(reader, "UrlPath"), SQLDataHelper.GetInt(reader, "BrandID")); siteMapData.Lastmod = DateTime.Now; } return siteMapData; }
/// <summary> /// write kine to xml /// </summary> /// <param name="item"></param> /// <param name="writer"></param> private void WriteLine(SiteMapData item, XmlWriter writer) { writer.WriteStartElement("url"); // url ------------- writer.WriteStartElement("loc"); writer.WriteString(item.Loc); writer.WriteEndElement(); writer.WriteStartElement("lastmod"); writer.WriteString(item.Lastmod.ToString("yyyy-MM-dd")); writer.WriteEndElement(); writer.WriteStartElement("changefreq"); writer.WriteString(item.Changefreq); writer.WriteEndElement(); writer.WriteStartElement("priority"); writer.WriteString(item.Priority.ToString(CultureInfo.InvariantCulture)); writer.WriteEndElement(); // url ------------- writer.WriteEndElement(); }