public override void Execute(Guid targetInstanceId) { try { foreach (SPSite site in WebApplication.Sites) { long lastmod = site.LastContentModifiedDate.Ticks; long lastrun = LastRunTime.Ticks; SPMonthlySchedule schedule = Schedule as SPMonthlySchedule; //Schedule.GetType() SiteMapSettings settings = new SiteMapSettings(); settings = settings.Load(site); foreach (string searchengine in settings.SearchEngines) { string sitemap = string.Format("{0}/indexmap.xml", site.RootWeb.Url); SubmitMap(searchengine, sitemap); if (settings.UseMobile) { sitemap = string.Format("{0}/mobilemap.xml", site.RootWeb.Url); SubmitMap(searchengine, sitemap); } if (settings.UseNews) { sitemap = string.Format("{0}/newsmap.xml", site.RootWeb.Url); SubmitMap(searchengine, sitemap); } if (settings.UseVideo) { sitemap = string.Format("{0}/videomap.xml", site.RootWeb.Url); SubmitMap(searchengine, sitemap); } } } this.UpdateProgress(100); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); } finally { } }
public void ProcessRequest(HttpContext context) { settings = new SiteMapSettings(); settings = settings.Load();//SPContext.Current.Site); SPWeb rootWeb; bool dispose = false; if (SPContext.Current != null) { rootWeb = SPContext.Current.Site.RootWeb; } else { SPSite site = new SPSite(context.Request.Url.ToString()); rootWeb = site.RootWeb; dispose = true; } //SPWeb web = SPContext.Current.Web; textWriter = new StringBuilder(string.Empty); if (rootWeb != null && rootWeb.Exists) { siteId = rootWeb.Site.ID; webId = rootWeb.Site.OpenWeb().ID; if (context.Request.Path.ToLower().Contains("index")) { BuildSiteIndex(); } if (context.Request.Path.ToLower().Contains("site")) { BuildSiteMap(); } if (context.Request.Path.ToLower().Contains("news")) { company = new CompanySettings(); company = company.Load(); BuildNewsMap(); } if (context.Request.Path.ToLower().Contains("video")) { BuildVideoMap(); } if (context.Request.Path.ToLower().Contains("mobile")) { BuildMobileMap(); } } context.Response.ContentEncoding = Encoding.UTF8; context.Response.ContentType = "text/xml"; context.Response.Buffer = false; context.Response.HeaderEncoding = Encoding.UTF8; context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.Write(textWriter.ToString()); context.Response.Flush(); context.Response.End(); if (dispose) { rootWeb.Dispose(); } ; }