protected void btnSave_Click(object sender, EventArgs args) { if (IsValid) { try { bool bGenerate = checkGenerateSitemap.Checked; string strFileName = txtFileName.Text; if (string.IsNullOrEmpty(strFileName)) { strFileName = Page.ResolveUrl("~/sitemap.xml"); } if (strFileName[0] != '/') { strFileName = string.Format("/{0}", strFileName); } bool bSitemapXmlIncludePage; bool bSitemapXmlIncludeLastMod; DateTime?dtSitemapXmlLastmod; bool bSitemapXmlIncludeChangeFreg; string strSitemapXmlChangeFreq; bool bSitemapXmlIncludePriority; decimal dSitemapXmlPriority; sitemapXmlEdit.GetSettings( out bSitemapXmlIncludePage, out bSitemapXmlIncludeLastMod, out dtSitemapXmlLastmod, out bSitemapXmlIncludeChangeFreg, out strSitemapXmlChangeFreq, out bSitemapXmlIncludePriority, out dSitemapXmlPriority); SitemapXmlSettings settings = new SitemapXmlSettings(); settings.Generate = bGenerate; settings.FileName = strFileName; settings.DefaultIncludePage = bSitemapXmlIncludePage; settings.DefaultIncludeLastMod = bSitemapXmlIncludeLastMod; settings.DefaultLastMod = dtSitemapXmlLastmod; settings.DefaultIncludeChangefreq = bSitemapXmlIncludeChangeFreg; settings.DefaultChangefreq = strSitemapXmlChangeFreq; settings.DefaultIncludePriority = bSitemapXmlIncludePriority; settings.DefaultPriority = dSitemapXmlPriority; SitemapXmlHelper.SaveSettings(settings); messageBox.ShowSuccess("Sitemap settings updated."); } catch (Exception ex) { string strMessage = "Failed saving sitemap settings"; BayshoreSolutions.WebModules.WebModulesAuditEvent.Raise(strMessage, this, ex); messageBox.ShowError(strMessage); } } }
protected void LoadSettings() { BayshoreSolutions.WebModules.WebpageInfo webpageInfo = new BayshoreSolutions.WebModules.WebpageInfo(); BayshoreSolutions.WebModules.SitemapXmlSettings settings = new SitemapXmlSettings(); SitemapXmlHelper.LoadSettings(out settings, true); checkGenerateSitemap.Checked = settings.Generate; txtFileName.Text = settings.FileName; webpageInfo.SitemapXml_IncludePage = settings.DefaultIncludePage; webpageInfo.SitemapXml_IncludeLastmod = settings.DefaultIncludeLastMod; webpageInfo.SitemapXml_LastModified = settings.DefaultLastMod; webpageInfo.SitemapXml_IncludeChangefreq = settings.DefaultIncludeChangefreq; webpageInfo.SitemapXml_Changefreq = settings.DefaultChangefreq; webpageInfo.SitemapXml_IncludePriority = settings.DefaultIncludePriority; webpageInfo.SitemapXml_Priority = settings.DefaultPriority; sitemapXmlEdit.WebpageInfo = webpageInfo; }