SharePoint : Programmatically access "Manage crawls of Site Directory"
Programmatically access "Manage crawls of Site Directory"
The Manage Crawls of Site directory is a Area Listing as like Best Bet Keywords. The following piece of code snippet can be used to access the "Manage crawls of Site Directory" through SPS object model. The crawl is part of DeepCrawl AreaListings. The Status (SiteDate.ListingStatus) property of AreaListings can be used to identify the "Approved, pending and rejected" status of the crawls of the site.
TopologyManager tm = new TopologyManager();
//Get the portal site <<Replace the hard coded url>>
PortalSite ps = tm.PortalSites[ new Uri("site url") ];
//Get the portal context
Microsoft.SharePoint.Portal.PortalContext ctx = Microsoft.SharePoint.Portal.PortalApplication.GetContext(ps);
//Get the Search area's guid
Guid uid = AreaManager.GetSystemAreaGuid(ctx,SystemArea.DeepCrawl);
//Get the Search area
Area DeepCrawlArea = AreaManager.GetArea(ctx, uid);
foreach(AreaListing listing in DeepCrawlArea.Listings)
MessageBox.Show(listing.Title + " : " + listing.Status.ToString());