Пример #1
0
        public static void WriteReportG()
        {
            var listSiteMapEntry = new List<SiteMapEntry>
                {
                    new SiteMapEntry
                    {
                        Loc = "nha-dat-3490"
                    }
                };

            var listSiteMapEntryLocation = new List<SiteMapEntry>();
            #region LISTING
            var listingModel = new SitemapData().GetListings();
            if (listingModel.Count > 0)
            {
                #region category-listing
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Level2Category.UrlFriendly() + "-" + item.Level2CategoryId
                }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                #endregion

                #region category-sub-category-listing
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId
                }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                #endregion

                //#region city
                //foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                //{
                //    Loc = item.State.UrlFriendly() + "-s" + item.StateId
                //}).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                //{
                //    listSiteMapEntryLocation.Add(siteMapEntry);
                //}
                //#endregion

                //#region city-district
                //foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                //{
                //    Loc = item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId
                //}).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                //{
                //    listSiteMapEntryLocation.Add(siteMapEntry);
                //}
                //#endregion

                //#region city-district-ward
                //foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                //{
                //    Loc = item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-" + item.Ward.UrlFriendly() + "-l" + item.WardId
                //}).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                //{
                //    listSiteMapEntryLocation.Add(siteMapEntry);
                //}
                //#endregion

                #region category-city-listing
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Level2Category.UrlFriendly() + "-" + item.Level2CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId
                }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                #endregion

                #region subcategory-category-city-listing
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId
                }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                #endregion

                #region category-city-district-listing
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId
                }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Level2Category.UrlFriendly() + "-" + item.Level2CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId
                }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                #endregion

                #region subcategory-category-city-district-listing
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId
                }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                #endregion

                #region category-city-district-ward-listing
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Level2Category.UrlFriendly() + "-" + item.Level2CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-" + item.Ward.UrlFriendly() + "-l" + item.WardId
                }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                #endregion

                #region subcategory-category-city-district-ward-listing
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-" + item.Ward.UrlFriendly() + "-l" + item.WardId
                }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                #endregion
            }

            #endregion

            #region PROJECT
            var projectModel = new SitemapData().GetProjects();
            if (projectModel.Count > 0)
            {
                #region category-project
                foreach (var siteMapEntry in projectModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Category.UrlFriendly() + "-" + item.CategoryId
                }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                #endregion

                #region category-city-project
                foreach (var siteMapEntry in projectModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId
                }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                #endregion

                #region category-city-district-project
                foreach (var siteMapEntry in projectModel.Select(item => new SiteMapEntry
                 {
                     Loc = item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId
                 }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                #endregion

                #region category-city-district-ward-project
                foreach (var siteMapEntry in projectModel.Select(item => new SiteMapEntry
                {
                    Loc = item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() +"-" + item.Ward.UrlFriendly() + "-l" + item.WardId
                }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                #endregion
            }
            #endregion

            #region BUSINESS
            var businessModel = new SitemapData().GetCompanies();
            if (businessModel.Count > 0)
            {
                #region category-business
                foreach (var siteMapEntry in businessModel.Select(item => new SiteMapEntry
                {
                    Loc = "doanh-nghiep/" + item.Category.UrlFriendly() + "-" + item.CategoryId
                }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                #endregion

                //#region category-city-business
                //foreach (var siteMapEntry in businessModel.Select(item => new SiteMapEntry
                //{
                //    Loc = item.Category.UrlFriendly() + "-" + item.CategoryId
                //}).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                //{
                //    listSiteMapEntryLocation.Add(siteMapEntry);
                //}
                //#endregion

                #region category-city-location-business
                foreach (var siteMapEntry in businessModel.Select(item => new SiteMapEntry
                {
                    Loc = "doanh-nghiep/" +item.Location.UrlFriendly() + "/" + item.Category.UrlFriendly() + "-" + item.CategoryId
                }).Where(siteMapEntry => listSiteMapEntryLocation.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntryLocation.Add(siteMapEntry);
                }
                #endregion
            }
            #endregion

            #region save csv file

            var list = listSiteMapEntry.Select(m => m.Loc).ToList();
            var listLocation = listSiteMapEntryLocation.Select(m => m.Loc).ToList();
            const string firstMath = "(^/";
            const string lastMath = "$)";

            const string path = "C:/dataReport.csv";
            var lines = new List<String>();
            if (!File.Exists(path))
            {
                File.Create(path).Close();
            }
            if (!File.Exists(path)) return;
            lines.AddRange(list);
            using (var writer = new StreamWriter(path, false))
            {
                foreach (var line in lines)
                {
                    writer.WriteLine(new StringBuilder().Append(firstMath).Append(line).Append(lastMath).ToString());
                }
                writer.Close();
            }

            // Location
            const string pathLocation = "C:/dataReportLocation.csv";
            var linesLocation = new List<String>();
            if (!File.Exists(pathLocation))
            {
                File.Create(pathLocation).Close();
            }
            if (!File.Exists(pathLocation)) return;
            linesLocation.AddRange(listLocation);
            using (var writer = new StreamWriter(pathLocation, false))
            {
                foreach (var line in linesLocation)
                {
                    writer.WriteLine(new StringBuilder().Append(firstMath).Append(line).Append(lastMath).ToString());
                }
                writer.Close();
            }
            #endregion
        }
Пример #2
0
        public static void WriteSiteMapForListing15Am()
        {
            //Create the XmlDocument.
            var doc = new XmlDocument();
            var xmltype = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";

            var sitemapHelper = new SiteMapHelper();
            var getDate = DateTime.Now;
            var listSiteMapEntry = new List<SiteMapEntry>();
            var siteMap = new XDocument();

            #region listing follow sub-category
            // Get list sub category listing
            var listCategory = new SitemapData().GetCategoryListingList();
            // Get 2000 newest by subcategory
            foreach (var category in listCategory)
            {
                var listingModel = new SitemapData().GetListingByCategory(category.CategoryId);
                listSiteMapEntry = new List<SiteMapEntry>();
                listSiteMapEntry.AddRange(listingModel.Select(item => new SiteMapEntry
                {
                    Loc =
                        "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" +
                        item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.Title.UrlFriendly() + "-" +
                        item.Id,
                    Lastmod = getDate,
                    Changefreq = "daily",
                    Priority = 0.9m
                }));
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                //Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + category.Level2Category.UrlFriendly() + "-" +
                        category.Category.UrlFriendly() + "-" + category.CategoryId + ConfigurationManager.AppSettings["extSitemap"]);
            }
            #endregion
        }
Пример #3
0
        public static void WriteSiteMapDaily()
        {
            //Create the XmlDocument.
            var doc = new XmlDocument();
            var xmltype = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";

            var sitemapHelper = new SiteMapHelper();
            var getDate = DateTime.Now;
            var listSiteMap = new List<SiteMapEntry>();
            var listSiteMapEntry = new List<SiteMapEntry>();
            var siteMap = new XDocument();

            #region LISTING
            var listingModel = new SitemapData().GetListings();
            if (listingModel.Count > 0)
            {
                #region category-listing
                listSiteMapEntry = new List<SiteMapEntry>();
                listSiteMapEntry.Add(new SiteMapEntry
                {
                    Loc = "http://www.muabannhadat.vn/nha-dat-3490",
                    Lastmod = getDate,
                    Changefreq = "daily",
                    Priority = 0.8m
                });
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() +
                            "-" + item.Level2CategoryId,
                    Lastmod = getDate,
                    Changefreq = "daily",
                    Priority = 0.8m
                }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                // Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-listing"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-listing"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region category-sub-category-listing
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc =
                        "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" +
                        item.Category.UrlFriendly() + "-" + item.CategoryId,
                    Lastmod = getDate,
                    Changefreq = "daily",
                    Priority = 0.8m
                }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                //Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-sub-category-listing"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-sub-category-listing"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region category-city-listing
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc =
                        "http://www.muabannhadat.vn/nha-dat-3490/" + item.State.UrlFriendly() + "-s" + item.StateId,
                    Lastmod = getDate,
                    Changefreq = "daily",
                    Priority = 0.8m
                }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }

                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                            {
                                Loc =
                                    "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Level2CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId,
                                Lastmod = getDate,
                                Changefreq = "daily",
                                Priority = 0.8m
                            }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                //Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-city-listing"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-city-listing"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region subcategory-category-city-listing
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                            {
                                Loc =
                                    "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId,
                                Lastmod = getDate,
                                Changefreq = "daily",
                                Priority = 0.8m
                            }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                //Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["subcategory-category-city-listing"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["subcategory-category-city-listing"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region category-city-district-listing
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc = "http://www.muabannhadat.vn/nha-dat-3490/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId,
                    Lastmod = getDate,
                    Changefreq = "daily",
                    Priority = 0.8m
                }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }

                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                            {
                                Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Level2CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId,
                                Lastmod = getDate,
                                Changefreq = "daily",
                                Priority = 0.8m
                            }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                //Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-city-district-listing"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-city-district-listing"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region subcategory-category-city-district-listing
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                            {
                                Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId,
                                Lastmod = getDate,
                                Changefreq = "daily",
                                Priority = 0.8m
                            }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                //Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["subcategory-category-city-district-listing"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["subcategory-category-city-district-listing"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region listing
                //var size = Convert.ToInt32(ConfigurationManager.AppSettings["sizeSitemap"]);
                //var countListingModel = listingModel.Count;
                //var totalPage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(countListingModel) / size));
                //for (var i = 1; i <= totalPage; i++)
                //{
                //    // Save to sitemap
                //    listSiteMap.Add(new SiteMapEntry
                //    {
                //        Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["listing"] + i + ConfigurationManager.AppSettings["extSitemap"],
                //        Lastmod = getDate
                //    });
                //}
                #endregion

                #region listing follow sub-category
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry
                {
                    Loc =
                        "http://www.muabannhadat.vn/sitemap/" + item.Level2Category.UrlFriendly() + "-" +
                        item.Category.UrlFriendly() + "-" + item.CategoryId
                }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                listSiteMap.AddRange(listSiteMapEntry.Select(siteMapEntry => new SiteMapEntry
                {
                    Loc = siteMapEntry.Loc + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                }));

                #endregion

                #region subcategory-category-city-project-listing
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["subcategory-category-city-project-listing"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region subcategory-category-city-district-project-listing
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["subcategory-category-city-district-project-listing"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion
            }
            #endregion

            #region PROJECT
            var projectModel = new SitemapData().GetProjects();
            if (projectModel.Count > 0)
            {
                #region category-project
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in projectModel.Select(item => new SiteMapEntry
                        {
                            Loc = "http://www.muabannhadat.vn/" + item.Category.UrlFriendly() + "-" + item.CategoryId,
                            Lastmod = getDate,
                            Changefreq = "daily",
                            Priority = 0.8m
                        }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                // Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-project"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-project"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region category-city-project
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in projectModel.Select(item => new SiteMapEntry
                            {
                                Loc = "http://www.muabannhadat.vn/" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId,
                                Lastmod = getDate,
                                Changefreq = "daily",
                                Priority = 0.8m
                            }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                // Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-city-project"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-city-project"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region category-city-district-project
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in projectModel.Select(item => new SiteMapEntry
                            {
                                Loc = "http://www.muabannhadat.vn/" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId,
                                Lastmod = getDate,
                                Changefreq = "daily",
                                Priority = 0.8m
                            }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                // Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-city-district-project"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-city-district-project"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region project
                listSiteMapEntry = new List<SiteMapEntry>();
                listSiteMapEntry.AddRange(projectModel.Select(item => new SiteMapEntry
                            {
                                Loc = "http://www.muabannhadat.vn/" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.Title.UrlFriendly() + "-" + item.Id,
                                Lastmod = getDate,
                                Changefreq = "daily",
                                Priority = 0.8m
                            }));
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                // Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["project"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["project"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion
            }

            var projectListingModel = new SitemapData().GetProjectListings();
            #region subcategory-category-city-project-listing
            listSiteMapEntry = new List<SiteMapEntry>();

            foreach (var siteMapEntry in projectListingModel.Select(item => new SiteMapEntry
            {
                Loc =
                    "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly()
                    + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId + "/" + item.ProjectName.UrlFriendly() + "-p" + item.ProjectId,
                Lastmod = getDate,
                Changefreq = "daily",
                Priority = 0.9m
            }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
            {
                listSiteMapEntry.Add(siteMapEntry);
            }
            siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
            doc.LoadXml((siteMap.ToString()));
            //Save the document to a file.
            doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["subcategory-category-city-project-listing"] + ConfigurationManager.AppSettings["extSitemap"]);
            #endregion

            #region subcategory-category-city-district-project-listing
            listSiteMapEntry = new List<SiteMapEntry>();
            foreach (var siteMapEntry in projectListingModel.Select(item => new SiteMapEntry
            {
                Loc =
                    "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId + "/" + item.ProjectName.UrlFriendly() + "-p" + item.ProjectId,
                Lastmod = getDate,
                Changefreq = "daily",
                Priority = 0.9m
            }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
            {
                listSiteMapEntry.Add(siteMapEntry);
            }
            siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
            doc.LoadXml((siteMap.ToString()));
            //Save the document to a file.
            doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["subcategory-category-city-district-project-listing"] + ConfigurationManager.AppSettings["extSitemap"]);
            #endregion

            #endregion

            #region BUSINESS
            var businessModel = new SitemapData().GetCompanies();
            if (businessModel.Count > 0)
            {
                #region category-business
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in businessModel.Select(item => new SiteMapEntry
                            {
                                Loc = "http://www.muabannhadat.vn/doanh-nghiep/" + item.Category.UrlFriendly() + "-" + item.CategoryId,
                                Lastmod = getDate,
                                Changefreq = "weekly",
                                Priority = 0.5m
                            }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                // Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-business"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-business"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region category-city-business
                listSiteMapEntry = new List<SiteMapEntry>();
                foreach (var siteMapEntry in businessModel.Select(item => new SiteMapEntry
                            {
                                //Loc = "http://www.muabannhadat.vn/doanh-nghiep/" + item.Category.UrlFriendly() + "-" + item.CategoryId + "?cmpsct=" + item.StateId,
                                Loc = "http://www.muabannhadat.vn/doanh-nghiep/" + item.Category.UrlFriendly() + "-" + item.CategoryId,
                                Lastmod = getDate,
                                Changefreq = "weekly",
                                Priority = 0.5m
                            }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc)))
                {
                    listSiteMapEntry.Add(siteMapEntry);
                }
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                // Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-city-business"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-city-business"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion

                #region business
                listSiteMapEntry = new List<SiteMapEntry>();
                //listSiteMapEntry.AddRange(businessModel.Select(item => new SiteMapEntry
                //{
                //    Loc = "http://www.muabannhadat.vn/doanh-nghiep/" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/detail/" + item.Name.UrlFriendly() + "-" + item.Id,
                //    Lastmod = getDate,
                //    Changefreq = "weekly",
                //    Priority = 0.5m
                //}));
                listSiteMapEntry.AddRange(businessModel.Select(item => new SiteMapEntry
                {
                    Loc = "http://www.muabannhadat.vn/doanh-nghiep/detail/" + item.Name.UrlFriendly() + "-" + item.Id,
                    Lastmod = getDate,
                    Changefreq = "weekly",
                    Priority = 0.5m
                }));
                siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry);
                doc.LoadXml((xmltype + siteMap));
                // Save the document to a file.
                doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["business"] + ConfigurationManager.AppSettings["extSitemap"]);
                // Save to sitemap
                listSiteMap.Add(new SiteMapEntry
                {
                    Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["business"] + ConfigurationManager.AppSettings["extSitemap"],
                    Lastmod = getDate
                });
                #endregion
            }
            #endregion

            // SITEMAP
            listSiteMap.Add(new SiteMapEntry
            {
                Loc = "http://www.muabannhadat.vn/tin-tuc/sitemap-3.xml",
                Lastmod = getDate
            });
            siteMap = sitemapHelper.GenerateSiteMapMain(listSiteMap);
            doc.LoadXml((xmltype + siteMap));
            //Save the document to a file.
            doc.Save(ConfigurationManager.AppSettings["pathSitemap"] + "sitemap.xml");
        }