private void CreateWorkItem(SPWeb web, string fullClass, string fullAssembly) { //SPSite tsite = properties.Feature.Parent as SPSite; Guid siteId = web.Site.ID; Guid webId = web.ID; string _modulename = fullClass; string _assembly = fullAssembly; SPSecurity.RunWithElevatedPrivileges(() => { using (SPSite site = new SPSite(siteId)) { site.AddWorkItem( Guid.NewGuid(), DateTime.Now.ToUniversalTime(), WebSiteControllerModuleWorkItem.WorkItemTypeId, webId, siteId, 1, true, Guid.Empty, Guid.Empty, site.SystemAccount.ID, null, _modulename + ";" + _assembly, Guid.Empty ); } }); try { WebSiteControllerModuleWorkItem WebSiteControllerModuleJob = new WebSiteControllerModuleWorkItem(WebSiteControllerModuleWorkItem.WorkItemJobDisplayName + "HomePage", web.Site.WebApplication); SPOneTimeSchedule oneTimeSchedule = new SPOneTimeSchedule(DateTime.Now); WebSiteControllerModuleJob.Schedule = oneTimeSchedule; WebSiteControllerModuleJob.Update(); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } }
private void CreateJobs_WebSiteController(SPFeatureReceiverProperties properties) { if (webApp != null) { DeleteJob(webApp.JobDefinitions); try { WebSiteControllerModuleWorkItem WebSiteControllerModuleJob = new WebSiteControllerModuleWorkItem(WebSiteControllerModuleWorkItem.WorkItemJobDisplayName, webApp); SPMinuteSchedule moduleschedule = new SPMinuteSchedule(); moduleschedule.BeginSecond = 0; moduleschedule.EndSecond = 59; moduleschedule.Interval = 1; WebSiteControllerModuleJob.Schedule = moduleschedule; WebSiteControllerModuleJob.Update(); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } try { WebSiteControllerRuleWorkItem WebSiteControllerRuleJob = new WebSiteControllerRuleWorkItem(WebSiteControllerRuleWorkItem.WorkItemJobDisplayName, webApp); SPMinuteSchedule ruleschedule = new SPMinuteSchedule(); ruleschedule.BeginSecond = 0; ruleschedule.EndSecond = 59; ruleschedule.Interval = 1; WebSiteControllerRuleJob.Schedule = ruleschedule; WebSiteControllerRuleJob.Update(); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } } }