private static void InstallJob(string webUrl, string jobName, string serverName) { SPServer appServer = null; foreach (var server in SPServer.Local.Farm.Servers) { if (server.Name.Equals(serverName, StringComparison.InvariantCultureIgnoreCase)) { appServer = server; break; } } if (appServer == null) { throw new Exception(String.Format("Server '{0}' was not found in the farm", serverName)); } var job = new MediaProcessingTimerJob(jobName, appServer); job.Properties.Add("webUrl", webUrl); var schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 15; job.Schedule = schedule; job.Update(); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; // make sure the job isn't already registered foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == List_JOB_NAME) { job.Delete(); } } // install the job ListTimerJob listLoggerJob = new ListTimerJob(List_JOB_NAME, site.WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 5; listLoggerJob.Schedule = schedule; listLoggerJob.Update(); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite Site = properties.Feature.Parent as SPSite; //Check if the Facebook event job is already created, then delete the job foreach (SPJobDefinition jobDef in Site.WebApplication.JobDefinitions) { if (jobDef.Name.Equals("BrickRed.Fcebook.Events")) { jobDef.Delete(); } } //Configure job BrickRed.WebParts.Facebook.Wall.FacebookEvents.FacebookEvents objJob = new BrickRed.WebParts.Facebook.Wall.FacebookEvents.FacebookEvents("BrickRed.Facebook.Events", Site.WebApplication); SPMinuteSchedule minSched = new SPMinuteSchedule(); minSched.BeginSecond = 0; minSched.EndSecond = 59; minSched.Interval = 2; objJob.Schedule = minSched; objJob.IsDisabled = true; objJob.Update(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { //In this event we create and install the timer job //Start by finding the SPSite. SPSite site = (SPSite)properties.Feature.Parent; //Make sure the timer job isn't already registered foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == TIMER_JOB_NAME) { job.Delete(); } } //Create a new Timer job GENERAL_CustomTimerJob newTimerJob = new GENERAL_CustomTimerJob(TIMER_JOB_NAME, site.WebApplication); //Configure the schedule and save it SPMinuteSchedule jobSchedule = new SPMinuteSchedule(); jobSchedule.BeginSecond = 0; jobSchedule.EndSecond = 59; jobSchedule.Interval = 5; newTimerJob.Schedule = jobSchedule; newTimerJob.Update(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; // make sure the job isn't already registered if (site != null) { foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == SPRequestJobName) { job.Delete(); } } // install the job SPRequestJob requestJob = new SPRequestJob(SPRequestJobName, site.WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 20; requestJob.Schedule = schedule; requestJob.Update(); } }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSecurity.RunWithElevatedPrivileges(delegate() { SPWeb web = properties.Feature.Parent as SPWeb; web.AllowUnsafeUpdates = true; SPWebApplication webApp = web.Site.WebApplication; foreach (SPJobDefinition job in webApp.JobDefinitions) if (job.Name == JOB_NAME) job.Delete(); string key = "mySiteUrl"; string value = web.Url; ChatterFeedTimerJob tmrJob = new ChatterFeedTimerJob(JOB_NAME, webApp); //remove the key if already exists bool isKeyExists = tmrJob.Properties.ContainsKey(key); if (isKeyExists) { tmrJob.Properties.Remove(key); } tmrJob.Properties.Add(key, value); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; //to start immediately schedule.EndSecond = 59; //use this if timer job is to end after some seconde schedule.Interval = 5; //number of minutes tmrJob.Schedule = schedule; tmrJob.Update(); web.AllowUnsafeUpdates = false; }); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebApplication webApp = properties.Feature.Parent as SPWebApplication; if (webApp != null) { // Remove the timer job if it exists RemoveTimerJobs(webApp); // Create schedule the timer job will process items every 15 minutes SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 1; // Create the Timer JOb and assign it a schedule GlymaExportWorkItemTimerJob exportWorkItem = new GlymaExportWorkItemTimerJob(webApp); exportWorkItem.Schedule = schedule; exportWorkItem.Update(); try { exportWorkItem.RunNow(); //run it immediately } catch { } } }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { var webApp = properties.Feature.Parent as SPWebApplication; if (webApp == null) throw new Exception("webApp"); // undeploy the job if already registered var ej = from SPJobDefinition job in webApp.JobDefinitions where job.Name == FileLoader.JOB_DEFINITION_NAME select job; if (ej.Count() > 0) ej.First().Delete(); // create and configure timerjob var schedule = new SPMinuteSchedule { BeginSecond = 0, EndSecond = 59, Interval = 55, }; var myJob = new FileLoader(webApp) { Schedule = schedule, IsDisabled = false }; // save the timer job deployment myJob.Update(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; // make sure the job isn't already registered foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == JOB_NAME) { job.Delete(); } } // install the job CaculateIndexJob Doc = new CaculateIndexJob(JOB_NAME, site.WebApplication); // 传递参数 Doc.Properties.Add("SiteUrl", site.Url); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 50; Doc.Schedule = schedule; Doc.Update(); }
private SPSchedule BuildMinuteSchedule() { SPMinuteSchedule schedule = null; int interval; int.TryParse(MinutesIntervalTextBox.Text, out interval); int beginSecond = 0; if (BeginSecondTextBox.Text.Length > 0) { int.TryParse(BeginSecondTextBox.Text, out beginSecond); } int endSecond = 59; if (EndSecondTextBox.Text.Length > 0) { int.TryParse(EndSecondTextBox.Text, out endSecond); } if (interval > 0) { schedule = new SPMinuteSchedule { Interval = interval, BeginSecond = beginSecond, EndSecond = endSecond }; } return(schedule); }
/// <summary> /// Constructor /// </summary> public IdentityServiceApplicationJobDefinition() { _defaultschedule = new SPMinuteSchedule(); _defaultschedule.Interval = 2; _defaultschedule.BeginSecond = 1; _defaultschedule.EndSecond = 59; this.Schedule = _defaultschedule; }
/// <summary> /// Constructor /// </summary> public IdentityServiceApplicationJobDefinition(IdentityServiceApplication serviceApplication, string name) : base(GenerateJobName(serviceApplication, name), serviceApplication.Service) { ArgumentValidator.IsNotNull(serviceApplication, "IdentityServiceApplication"); _serviceApplicationId = serviceApplication.Id; _defaultschedule = new SPMinuteSchedule(); _defaultschedule.Interval = 2; _defaultschedule.BeginSecond = 1; _defaultschedule.EndSecond = 59; this.Schedule = _defaultschedule; }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { DeleteExistingJob(properties); // install the job ListTimerJob listLoggerJob = new ListTimerJob(List_JOB_NAME, (properties.Feature.Parent as SPSite).WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule { BeginSecond = 0, EndSecond = 59, Interval = 5 }; listLoggerJob.Schedule = schedule; listLoggerJob.Update(); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebApplication webApp = properties.Feature.Parent as SPWebApplication; DeleteJob(webApp.JobDefinitions); ReportJobDefinition simpleJob = new ReportJobDefinition(webApp); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 1; simpleJob.Schedule = schedule; simpleJob.Update(); }
private void RegisterJob(SPWebApplication webApp) { DeleteJob(webApp); SubJob job = new SubJob(webApp, "http://localhost"); SPMinuteSchedule scheduleSubJob = new SPMinuteSchedule(); scheduleSubJob.BeginSecond = 0; scheduleSubJob.EndSecond = 15; scheduleSubJob.Interval = 1; job.Schedule = scheduleSubJob; job.Update(); }
private void RegisterJob(SPWebApplication webApp) { DeleteJob(webApp); SubWorkItemJob workItemJob = new SubWorkItemJob("Mighty Job", webApp); SPMinuteSchedule scheduleWorkItemJob = new SPMinuteSchedule(); scheduleWorkItemJob.BeginSecond = 0; scheduleWorkItemJob.EndSecond = 15; scheduleWorkItemJob.Interval = 1; workItemJob.Schedule = scheduleWorkItemJob; workItemJob.Update(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebApplication webApplication = properties.Feature.Parent as SPWebApplication; DeleteJob(webApplication.JobDefinitions); ApprovedEstimatesJob estimatesJob = new ApprovedEstimatesJob(webApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 5; estimatesJob.Schedule = schedule; estimatesJob.Update(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebApplication webApp = properties.Feature.Parent as SPWebApplication; DeleteJob(webApp.JobDefinitions); SimbleJobDefinition simpleJob = new SimbleJobDefinition(webApp); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 1; simpleJob.Schedule = schedule; simpleJob.Update(); }
/// <summary> /// Create / update Job to copy items /// </summary> private static void CreateDeleteJob(SPWeb web) { // THE ORIGINAL VALUE OF REMOTE ADMINISTRATOR var remoteAdministratorAccessDenied = SPWebService.ContentService.RemoteAdministratorAccessDenied; try { Logger.WriteMessage("SkillWillCorp.SP.Offices.SkillWillCorpSPOfficesEventReceiver: Create timers to copy elements"); // SET THE REMOTE ADMINISTATOR ACCESS DENIED FALSE SPWebService.ContentService.RemoteAdministratorAccessDenied = false; Logger.WriteMessage("SkillWillCorp.SP.Offices.SkillWillCorpSPOfficesEventReceiver: Initialize new instance for ListSynchronizationJob"); var copyJob = new ListSynchronizationJob(web.Site.WebApplication, web); Logger.WriteMessage("SkillWillCorp.SP.Offices.SkillWillCorpSPOfficesEventReceiver: DeleteIfExistJob"); copyJob.DeleteIfExistJob(); Logger.WriteMessage("SkillWillCorp.SP.Offices.SkillWillCorpSPOfficesEventReceiver: Initialize SPMinuteSchedule"); var schedule = new SPMinuteSchedule { Interval = 30 }; copyJob.Schedule = schedule; Logger.WriteMessage("SkillWillCorp.SP.Offices.SkillWillCorpSPOfficesEventReceiver: Update copyJob"); copyJob.Update(); Logger.WriteMessage("SkillWillCorp.SP.Offices.SkillWillCorpSPOfficesEventReceiver: Start copyJob"); try { copyJob.RunNow(); } catch { } } catch (Exception ex) { Logger.WriteError("SkillWillCorp.SP.Offices.SkillWillCorpSPOfficesEventReceiver: Critical error on CreateTimeJob, message", ex, TraceSeverity.Unexpected); throw new Exception(string.Format("Critical error on CreateTimeJob, message : {0}", ex.Message)); } finally { // SET THE REMOTE ADMINISTATOR ACCESS DENIED BACK WHAT // IT WAS SPWebService.ContentService.RemoteAdministratorAccessDenied = remoteAdministratorAccessDenied; } }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite site = properties.Feature.Parent as SPSite; // make sure the job isn't already registered site.WebApplication.JobDefinitions.Where(t => t.Name.Equals(List_JOB_NAME)).ToList().ForEach(j => j.Delete()); //job a cada 30min MonitoraJob listLoggerJob = new MonitoraJob(List_JOB_NAME, site.WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.Interval = 30; listLoggerJob.Schedule = schedule; listLoggerJob.Update(); }); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == MY_TASK) { job.Delete(); } } WarmUpTimerJobCS timer = new WarmUpTimerJobCS(MY_TASK, site.WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 10; timer.Schedule = schedule; timer.Update(); }
private bool CreateJob(SPWebApplication site) { bool jobCreated = false; try { OurCustomTimerJob job = new OurCustomTimerJob(JobName, site); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 5; job.Schedule = schedule; job.Update(); } catch (Exception) { return(jobCreated); } return(jobCreated); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; // make sure the job isn't already registered foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == CLRSurvey_JOB_NAME) job.Delete(); } // install the job CLRSurveyTimerJob CLRSurveyTimerJobLogger = new CLRSurveyTimerJob(CLRSurvey_JOB_NAME, site.WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 10; CLRSurveyTimerJobLogger.Schedule = schedule; CLRSurveyTimerJobLogger.Update(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Title == TimerJobName) { job.Delete(); } } CustomTimerJob UpdateTitle = new CustomTimerJob(TimerJobName, site.WebApplication); SPMinuteSchedule minuteSchedule = new SPMinuteSchedule(); minuteSchedule.BeginSecond = 0; minuteSchedule.EndSecond = 59; minuteSchedule.Interval = 1; UpdateTitle.Schedule = minuteSchedule; UpdateTitle.Update(); }
private bool CreateJob(SPWebApplication site) { bool jobCreated = false; try { TaskEmailReminderTimerJob job = new TaskEmailReminderTimerJob(List_JOB_NAME, site); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 15; job.Schedule = schedule; job.Update(); } catch (Exception) { return(jobCreated); } return(jobCreated); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebApplication webApp = properties.Feature.Parent as SPWebApplication; foreach (SPJobDefinition job in webApp.JobDefinitions) { if (job.Name == "Process Intructor Schedules") { job.Delete(); } TJ_ProcessInstructorSchedules timerJob = new TJ_ProcessInstructorSchedules("Process Instructor Schedules", webApp); timerJob.Title = "Process Instructor Schedules"; SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 1; timerJob.Schedule = schedule; timerJob.Update(); } }
private void AddTimerJobs(SPWebApplication webApp) { RemoveTimerJobs(webApp); var ironLogSchedule = new SPMinuteSchedule { Interval = 1, BeginSecond = 0, EndSecond = 59 }; var ironLogJobDefinition = new IronLogWorkItemJobDefinition(webApp) { Schedule = ironLogSchedule }; ironLogJobDefinition.Update(); try { ironLogJobDefinition.RunNow(); } catch { } }
private bool CreateJob(SPWebApplication site) { bool jobCreated = false; try { Unprocessed_Performance job = new Unprocessed_Performance(JobName, site); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 15; job.Schedule = schedule; job.Update(); } catch (Exception) { return(jobCreated); } return(jobCreated); }
private bool CreateJob(SPWebApplication site) { bool jobCreated = false; try { ImportCaseInfo job = new ImportCaseInfo(JobName, site); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 10; job.Schedule = schedule; job.Update(); } catch (Exception) { return(jobCreated); } return(jobCreated); }
private bool CreateTimeOffCalendarSyncJob(SPWebApplication webApp) { bool jobCreated = false; try { CalendarSyncJob job = new CalendarSyncJob(JobName, webApp); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.Interval = 15; job.Schedule = schedule; job.Update(); jobCreated = true; } catch (Exception ex) { Util.LogError("Error creating time off calendar sync job: " + ex.Message); } return(jobCreated); }
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(); } } }
/// <summary> /// Occurs after a Feature is activated. /// </summary> /// <param name="properties">An <see cref="T:Microsoft.SharePoint.SPFeatureReceiverProperties"></see> object that represents the properties of the event.</param> public override void FeatureActivated(SPFeatureReceiverProperties properties) { // register the the current web SPSite site = properties.Feature.Parent as SPSite; // make sure the job isn't already registered foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == TIMER_JOB_NAME) job.Delete(); } // install the job DeleteMarkedItems taskLoggerJob = new DeleteMarkedItems(TIMER_JOB_NAME, site.WebApplication); SPMinuteSchedule minuteSchedule = new SPMinuteSchedule(); minuteSchedule.BeginSecond = 0; minuteSchedule.EndSecond = 59; minuteSchedule.Interval = 1; taskLoggerJob.Schedule = minuteSchedule; //SPDailySchedule.FromString("daily at 23:59:59"); taskLoggerJob.Update(); }
public void InstallFirstTimerJob(SPWeb web) { DeleteFirstTimerJob(web); try { // install the timer job SampleTimerJob objFirstTimer = new SampleTimerJob("$safeprojectname$ First Timer Job", web.Site.WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.Interval = 15; schedule.BeginSecond = 0; schedule.EndSecond = 0; objFirstTimer.Schedule = schedule; objFirstTimer.Update(); } catch (Exception ex) { throw ex; } }
/// <summary> /// Invoke on Feature Activation /// </summary> /// <param name="properties"></param> public override void FeatureActivated(SPFeatureReceiverProperties properties) { try { SPSite site = properties.Feature.Parent as SPSite; jobTitle = jobTitle + site.Url.ToString(); // Delete Existing Timer Job If Installed foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name.Equals(jobTitle, StringComparison.InvariantCultureIgnoreCase)) { job.Delete(); } } AlertJobdefinition objArchivalJob = new AlertJobdefinition(jobTitle, site.WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); if (schedule != null) { schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 30; objArchivalJob.Properties.Add(WebSiteURL_KeyName, site.Url); objArchivalJob.Schedule = schedule; objArchivalJob.Update(); } //Creating Hidden List1 SPWeb web = site.OpenWeb(); SPListCollection lists = web.Lists; lists.Add("CCSAdvancedAlertsList", "CrowCanyon Advanced Alerts List", SPListTemplateType.GenericList); SPList newList = web.Lists["CCSAdvancedAlertsList"]; newList.Fields.Add("WebID", SPFieldType.Text, false); newList.Fields.Add("ListID", SPFieldType.Text, false); newList.Fields.Add("ItemID", SPFieldType.Text, false); newList.Fields.Add("WhenToSend", SPFieldType.Choice, false); SPFieldChoice WhenToSendChoiceCol = (SPFieldChoice)newList.Fields["WhenToSend"]; string[] strdata = new string[3]; strdata[0] = "Immediate"; strdata[1] = "Daily"; strdata[2] = "Weekely"; WhenToSendChoiceCol.Choices.Add(strdata[0]); WhenToSendChoiceCol.Choices.Add(strdata[1]); WhenToSendChoiceCol.Choices.Add(strdata[2]); WhenToSendChoiceCol.Update(); newList.Fields.Add("DetailInfo", SPFieldType.Note, false); newList.Fields.Add("Owner", SPFieldType.User, false); newList.Fields.Add("EventType", SPFieldType.Choice, false); SPFieldChoice EventTypeChoiceCol = (SPFieldChoice)newList.Fields["EventType"]; string[] strdata1 = new string[4]; strdata1[0] = "ItemAdded"; strdata1[1] = "ItemUpdated"; strdata1[2] = "ItemDeleted"; strdata1[3] = "DateColumn"; EventTypeChoiceCol.Choices.Add(strdata1[0]); EventTypeChoiceCol.Choices.Add(strdata1[1]); EventTypeChoiceCol.Choices.Add(strdata1[2]); EventTypeChoiceCol.Choices.Add(strdata1[3]); EventTypeChoiceCol.Update(); newList.Fields.Add("SendDay", SPFieldType.Choice, false); SPFieldChoice SendDayChoiceCol = (SPFieldChoice)newList.Fields["SendDay"]; string[] strdata2 = new string[7]; strdata2[0] = "1"; strdata2[1] = "2"; strdata2[2] = "3"; strdata2[3] = "4"; strdata2[4] = "5"; strdata2[5] = "6"; strdata2[6] = "7"; SendDayChoiceCol.Choices.Add(strdata2[0]); SendDayChoiceCol.Choices.Add(strdata2[1]); SendDayChoiceCol.Choices.Add(strdata2[2]); SendDayChoiceCol.Choices.Add(strdata2[3]); SendDayChoiceCol.Choices.Add(strdata2[4]); SendDayChoiceCol.Choices.Add(strdata2[5]); SendDayChoiceCol.Choices.Add(strdata2[6]); SendDayChoiceCol.Update(); newList.Fields.Add("SendHour", SPFieldType.Choice, false); SPFieldChoice SendHourChoiceCol = (SPFieldChoice)newList.Fields["SendHour"]; string[] strdata3 = new string[24]; strdata3[0] = "0"; strdata3[1] = "1"; strdata3[2] = "2"; strdata3[3] = "3"; strdata3[4] = "4"; strdata3[5] = "5"; strdata3[6] = "6"; strdata3[7] = "7"; strdata3[8] = "8"; strdata3[9] = "9"; strdata3[10] = "10"; strdata3[11] = "11"; strdata3[12] = "12"; strdata3[13] = "13"; strdata3[14] = "14"; strdata3[15] = "15"; strdata3[16] = "16"; strdata3[17] = "17"; strdata3[18] = "18"; strdata3[19] = "19"; strdata3[20] = "20"; strdata3[21] = "21"; strdata3[22] = "22"; strdata3[23] = "23"; SendHourChoiceCol.Choices.Add(strdata3[0]); SendHourChoiceCol.Choices.Add(strdata3[1]); SendHourChoiceCol.Choices.Add(strdata3[2]); SendHourChoiceCol.Choices.Add(strdata3[3]); SendHourChoiceCol.Choices.Add(strdata3[4]); SendHourChoiceCol.Choices.Add(strdata3[5]); SendHourChoiceCol.Choices.Add(strdata3[6]); SendHourChoiceCol.Choices.Add(strdata3[7]); SendHourChoiceCol.Choices.Add(strdata3[8]); SendHourChoiceCol.Choices.Add(strdata3[9]); SendHourChoiceCol.Choices.Add(strdata3[10]); SendHourChoiceCol.Choices.Add(strdata3[11]); SendHourChoiceCol.Choices.Add(strdata3[12]); SendHourChoiceCol.Choices.Add(strdata3[13]); SendHourChoiceCol.Choices.Add(strdata3[14]); SendHourChoiceCol.Choices.Add(strdata3[15]); SendHourChoiceCol.Choices.Add(strdata3[16]); SendHourChoiceCol.Choices.Add(strdata3[17]); SendHourChoiceCol.Choices.Add(strdata3[18]); SendHourChoiceCol.Choices.Add(strdata3[19]); SendHourChoiceCol.Choices.Add(strdata3[20]); SendHourChoiceCol.Choices.Add(strdata3[21]); SendHourChoiceCol.Choices.Add(strdata3[22]); SendHourChoiceCol.Choices.Add(strdata3[23]); SendHourChoiceCol.Update(); SPView view = newList.DefaultView; view.ViewFields.Add("WebID"); view.ViewFields.Add("ListID"); view.ViewFields.Add("ItemID"); view.ViewFields.Add("WhenToSend"); view.ViewFields.Add("DetailInfo"); view.ViewFields.Add("Owner"); view.ViewFields.Add("EventType"); view.ViewFields.Add("SendDay"); view.ViewFields.Add("SendHour"); view.Update(); newList.Hidden = true; newList.Update(); //Creating Hidden List2 lists.Add("CCSAdvancedAlertsMailTemplates", "CrowCanyon Advanced Alerts Mail Templates", SPListTemplateType.GenericList); SPList newList2 = web.Lists["CCSAdvancedAlertsMailTemplates"]; newList2.Fields.Add("InsertUpdatedFields", SPFieldType.Boolean, false); newList2.Fields.Add("HighLightUpdatedFields", SPFieldType.Boolean, false); newList2.Fields.Add("InsertAttachments", SPFieldType.Boolean, false); newList2.Fields.Add("Owner", SPFieldType.User, false); newList2.Fields.Add("Subject", SPFieldType.Text, false); newList2.Fields.Add("Body", SPFieldType.Note, false); SPView view2 = newList2.DefaultView; view2.ViewFields.Add("InsertUpdatedFields"); view2.ViewFields.Add("HighLightUpdatedFields"); view2.ViewFields.Add("InsertAttachments"); view2.ViewFields.Add("Owner"); view2.ViewFields.Add("Subject"); view2.ViewFields.Add("Body"); view2.Update(); newList2.Hidden = true; newList2.Update(); // Creating Hidden List3 lists.Add("CCSAdvancedTemplateForAlert", "CrowCanyon Advanced Template for alert", SPListTemplateType.GenericList); SPList newList3 = web.Lists["CCSAdvancedTemplateForAlert"]; newList3.Fields.AddLookup("Template", newList2.ID, false); SPFieldLookup lkp = (SPFieldLookup)newList3.Fields["Template"]; lkp.LookupField = newList2.Fields["Title"].InternalName; newList3.Fields.Add("EventType", SPFieldType.Choice, false); SPFieldChoice EventTypeChoiceCol2 = (SPFieldChoice)newList3.Fields["EventType"]; string[] strdata4 = new string[4]; strdata4[0] = "ItemAdded"; strdata4[1] = "ItemUpdated"; strdata4[2] = "ItemDeleted"; strdata4[3] = "DateColumn"; EventTypeChoiceCol2.Choices.Add(strdata4[0]); EventTypeChoiceCol2.Choices.Add(strdata4[1]); EventTypeChoiceCol2.Choices.Add(strdata4[2]); EventTypeChoiceCol2.Choices.Add(strdata4[3]); EventTypeChoiceCol2.Update(); newList3.Fields.Add("InsertUpdatedFields", SPFieldType.Boolean, false); newList3.Fields.Add("HighLightUpdatedFields", SPFieldType.Boolean, false); newList3.Fields.Add("InsertAttachments", SPFieldType.Boolean, false); newList3.Fields.AddLookup("Alert", newList.ID, false); SPFieldLookup lkp2 = (SPFieldLookup)newList3.Fields["Alert"]; lkp2.LookupField = newList.Fields["Title"].InternalName; newList3.Update(); SPView view3 = newList3.DefaultView; view3.ViewFields.Add("Template"); view3.ViewFields.Add("EventType"); view3.ViewFields.Add("InsertUpdatedFields"); view3.ViewFields.Add("HighLightUpdatedFields"); view3.ViewFields.Add("InsertAttachments"); view3.ViewFields.Add("Alert"); view3.Update(); newList3.Hidden = true; newList3.Update(); //Creating Hidden List 4 lists.Add("CCSAdvancedDelayedAlerts", "CrowCanyon Advanced Delayed Alerts", SPListTemplateType.GenericList); SPList newList4 = web.Lists["CCSAdvancedDelayedAlerts"]; newList4.Fields.Add("Subject", SPFieldType.Text, false); newList4.Fields.Add("Body", SPFieldType.Note, false); newList4.Fields.Add("EventType", SPFieldType.Choice, false); SPFieldChoice EventTypeChoiceCol3 = (SPFieldChoice)newList4.Fields["EventType"]; string[] strdata5 = new string[4]; strdata5[0] = "ItemAdded"; strdata5[1] = "ItemUpdated"; strdata5[2] = "ItemDeleted"; strdata5[3] = "DateColumn"; EventTypeChoiceCol3.Choices.Add(strdata5[0]); EventTypeChoiceCol3.Choices.Add(strdata5[1]); EventTypeChoiceCol3.Choices.Add(strdata5[2]); EventTypeChoiceCol3.Choices.Add(strdata5[3]); EventTypeChoiceCol3.Update(); newList4.Fields.AddLookup("Alert", newList.ID, false); SPFieldLookup lkp3 = (SPFieldLookup)newList4.Fields["Alert"]; lkp3.LookupField = newList.Fields["Title"].InternalName; newList4.Fields.Add("ItemID", SPFieldType.Text, false); newList4.Update(); SPView view4 = newList4.DefaultView; view4.ViewFields.Add("Subject"); view4.ViewFields.Add("Body"); view4.ViewFields.Add("EventType"); view4.ViewFields.Add("Alert"); view4.ViewFields.Add("ItemID"); view4.Update(); newList4.Hidden = true; newList4.Update(); } catch (System.Exception Ex) { } }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { WBLogging.Generic.HighLevel("TimerJobsEventReceiver.FeatureActivated(): Activating the WBF Timer Jobs feature"); SPWebApplication webApplication = properties.Feature.Parent as SPWebApplication; bool onSharePointHub = false; if (webApplication.Name.ToLower().Contains("sharepointhub")) { onSharePointHub = true; } foreach (SPAlternateUrl alternateUrl in webApplication.AlternateUrls) { if (alternateUrl.IncomingUrl.ToString().ToLower() == "http://sharepointhub/") { onSharePointHub = true; break; } } // So if we're not on the SharePointHub web application then we'll just end the activation process here: if (!onSharePointHub) { WBLogging.Generic.HighLevel("TimerJobsEventReceiver.FeatureActivated(): No activation is being done as we are on: " + webApplication.Name); return; } WBLogging.Generic.Verbose("TimerJobsEventReceiver.FeatureActivated(): Activation is happening on SharePointHub."); // make sure the job isn't already registered foreach (SPJobDefinition job in webApplication.JobDefinitions) { if (job.Name == WBTimerTasksJob.DAILY_TIMER_TASKS__TIMER_JOB_NAME) { job.Delete(); } if (job.Name == WBTimerTasksJob.FREQUENT_TIMER_TASKS__TIMER_JOB_NAME) { job.Delete(); } if (job.Name == WBMigrationTimerJob.MIGRATION_TIMER_JOB__TIMER_JOB_NAME) { job.Delete(); } } SPServer server = null; WBFarm farm = WBFarm.Local; if (farm.TimerJobsServerName != "") { server = farm.SPFarm.Servers[farm.TimerJobsServerName]; if (server != null) { /* */ /* First adding the Daily Timer Job */ /* */ WBLogging.Generic.HighLevel("TimerJobsEventReceiver.FeatureActivated(): Adding a timer job to server : " + server.Name + " with name: " + WBTimerTasksJob.DAILY_TIMER_TASKS__TIMER_JOB_NAME); WBTimerTasksJob timerJob = new WBTimerTasksJob( WBTimerTasksJob.DAILY_TIMER_TASKS__TIMER_JOB_NAME, WBTimerTasksJob.DAILY_TIMER_TASKS__LIST_NAME, WBTimerTasksJob.DAILY_TIMER_TASKS__ORDERED_VIEW_NAME, webApplication, server, SPJobLockType.Job); SPDailySchedule schedule = new SPDailySchedule(); schedule.BeginHour = 5; schedule.BeginMinute = 0; schedule.BeginSecond = 0; schedule.EndHour = 5; schedule.EndMinute = 10; schedule.EndSecond = 0; timerJob.Schedule = schedule; timerJob.Update(); /* */ /* Now adding the Frequent Timer Job */ /* */ WBLogging.Generic.HighLevel("TimerJobsEventReceiver.FeatureActivated(): Adding a timer job to server : " + server.Name + " with name: " + WBTimerTasksJob.FREQUENT_TIMER_TASKS__TIMER_JOB_NAME); WBTimerTasksJob frequentTimerJob = new WBTimerTasksJob( WBTimerTasksJob.FREQUENT_TIMER_TASKS__TIMER_JOB_NAME, WBTimerTasksJob.FREQUENT_TIMER_TASKS__LIST_NAME, WBTimerTasksJob.FREQUENT_TIMER_TASKS__ORDERED_VIEW_NAME, webApplication, server, SPJobLockType.Job); SPMinuteSchedule frequentSchedule = new SPMinuteSchedule(); frequentSchedule.BeginSecond = 0; frequentSchedule.EndSecond = 59; frequentSchedule.Interval = 10; frequentTimerJob.Schedule = frequentSchedule; frequentTimerJob.Update(); /* */ /* Now adding the Mirgation Timer Job */ /* */ WBLogging.Generic.HighLevel("TimerJobsEventReceiver.FeatureActivated(): Adding a timer job to server : " + server.Name + " with name: " + WBMigrationTimerJob.MIGRATION_TIMER_JOB__TIMER_JOB_NAME); WBMigrationTimerJob migrationTimerJob = new WBMigrationTimerJob( WBMigrationTimerJob.MIGRATION_TIMER_JOB__TIMER_JOB_NAME, webApplication, server, SPJobLockType.Job); SPWeeklySchedule migrationTimerJobSchedule = new SPWeeklySchedule(); migrationTimerJobSchedule.BeginDayOfWeek = System.DayOfWeek.Monday; migrationTimerJobSchedule.BeginHour = 5; migrationTimerJobSchedule.BeginMinute = 0; migrationTimerJobSchedule.BeginSecond = 0; migrationTimerJobSchedule.EndDayOfWeek = System.DayOfWeek.Monday; migrationTimerJobSchedule.EndHour = 5; migrationTimerJobSchedule.EndMinute = 10; migrationTimerJobSchedule.EndSecond = 0; migrationTimerJob.Schedule = migrationTimerJobSchedule; migrationTimerJob.Update(); } else { WBLogging.Generic.Unexpected("TimerJobsEventReceiver.FeatureActivated(): Couldn't find the server with the name: " + farm.TimerJobsServerName); } } else { WBLogging.Generic.Unexpected("TimerJobsEventReceiver.FeatureActivated(): The WBF farm wide setting of which server to use for the timer job has not been set."); } }