Nimekuwa kazi pamoja na baadhi ya kanuni kwamba mtu mitupu kwangu kwa ajili ya kazi timer. Yeye alikuwa zinazotolewa halisi kipengele uanzishaji kanuni hivyo nilikuwa na kuandika, bila shaka. Nilitumia faida za Andrew Connell maarufu blog post juu ya somo.
Mimi nina kutumia Visual Studio 2010 and deployment kept failing with an error “Error occurred in deployment step ‘Add Solution’: Kitu kumbukumbu si kuweka mfano wa kitu. "
Nilikuwa kuchukua kanuni yake pia literally. Nilikuwa scoping kipengele kwa ngazi ya maombi ya mtandao, kama inavyoonekana:
Kama matokeo, mali kwamba waliotumwa receiver ni kutoka maombi ya mtandao, sio mkusanyiko tovuti. Katika mwisho, kanuni inaonekana kama hii:
umma override utupu FeatureActivated(SPFeatureReceiverProperties mali)
{// Je, si kufanya yafuatayo na mtandao makala programu scoped, inaongoza kwa kukata tamaa
// SPSite tovuti = properties.Feature.Parent kama SPSite;SPWebApplication Wa = properties.Feature.Parent kama SPWebApplication;
kama (wa == null) kutupa Ubaguzi mpya("webapp2 is null.");
foreach (SPJobDefinition kazi katika wa.JobDefinitions)
{kujaribu
{
kama (job.Name == List_JOB_NAME)job.Delete();
}
kukamata (Ubaguzi e)
{
kutupa Ubaguzi mpya("marker 2");
} // kukamata ubaguzi e
}// kufunga kazi
WeatherForecastTimerJob weatherForecastTimerJob =
mpya WeatherForecastTimerJob(List_JOB_NAME, Wa);SPMinuteSchedule ratiba = mpya SPMinuteSchedule();
schedule.BeginSecond = 0;
schedule.EndSecond = 59;
schedule.Interval = 5;
weatherForecastTimerJob.Schedule = ratiba;
weatherForecastTimerJob.Update();}
muhimu kuchukua-mbali ni kwamba wakati kipengele ni scoped kwa programu mtandao, SPFeatureReceiverProperties kwamba SharePoint hupita kwa kipengele receiver yako ina mtandao vigezo ngazi ya programu. Andrew ya zamani blog kuingia akubali ni scoped kwa ukusanyaji tovuti.
</mwisho>
Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin