Bonsoir,
je veux associer un timer job à un sous site mais le problème est que ce code ne fonctionne que pour le site et non pas le sous site.En effet,il est util pour une liste dans le site et non plus pour une dans le sous site .
public override void Execute(Guid targetInstanceId)
{
//Get the Web Application in which this Timer Job runs
SPWebApplication webApp = this.Parent as SPWebApplication;
//Get the site collection
SPSiteCollection timerSiteCollection = webApp.ContentDatabases[targetInstanceId].Sites;
//Get the Announcements list in the RootWeb of each SPSite
SPList timerJobList = null;
foreach (SPSite site in timerSiteCollection)
{
timerJobList = site.RootWeb.Lists.TryGetList("cc");
if (timerJobList != null)
{
SPListItem newItem = timerJobList.Items.Add();
newItem["Title"] = "Today is " + DateTime.Today.ToLongDateString();
newItem.Update();
}
}
}
Merci d'avance pour votre aide :)
ghada