示例#1
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            var local = SPFarm.Local;

            var services = from s in local.Services
                           where s.Name == "SPTimerV4"
                           select s;

            var service = services.First();

            foreach (var job in service.JobDefinitions)
            {
                if (job.Name == tJobName)
                {
                    job.Delete();
                }
            }

            var newTimerJob = new ADLDSImportJob(tJobName, service);

            var jobSchedule = new SPHourlySchedule {
                BeginMinute = 0, EndMinute = 59
            };

            newTimerJob.Schedule = jobSchedule;
            newTimerJob.Update();
        }
示例#2
0
        // Uncomment the method below to handle the event raised after a feature has been activated.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            try
            {
                //SPSite site = properties.Feature.Parent as SPSite;
                SPSecurity.RunWithElevatedPrivileges(delegate() {
                    SPWebApplication parentWebApp = (SPWebApplication)properties.Feature.Parent;
                    // make sure the job isn't already registered
                    foreach (SPJobDefinition job in parentWebApp.JobDefinitions)
                    {
                        if (job.Name == "Piwik PRO Analytics Job")
                        {
                            job.Delete();
                            break;
                        }
                    }
                    // install the job
                    PiwikPROJSProvisioningJob corpProfileJob = new PiwikPROJSProvisioningJob("Piwik PRO Analytics Job", parentWebApp);
                    // Updates the timer schedule values
                    SPHourlySchedule schedule = new SPHourlySchedule();
                    schedule.BeginMinute      = 0;
                    schedule.EndMinute        = 5;
                    corpProfileJob.Schedule   = schedule;
                    parentWebApp.JobDefinitions.Add(corpProfileJob);
                });
            }
            catch (Exception ex)
            {
                Logger.WriteLog(Logger.Category.Unexpected, "Piwik FeatureActivated timer job", ex.Message);
            }
        }
示例#3
0
    private SPSchedule BuildHourlySchedule()
    {
        int beginMinute = 0;

        if (BeginMinuteTextBox.Text.Length > 0)
        {
            int.TryParse(BeginMinuteTextBox.Text, out beginMinute);
        }
        int endMinute = 59;

        if (EndMinuteTextBox.Text.Length > 0)
        {
            int.TryParse(EndMinuteTextBox.Text, out endMinute);
        }
        var schedule = new SPHourlySchedule {
            BeginMinute = beginMinute, EndMinute = endMinute
        };

        return(schedule);
    }
        //Função cria o TimerJob
        private bool CreateJob(SPWebApplication site)
        {
            bool jobCreated = false;

            try
            {
                Empresa.setor.TimerJob.TimerJob.TimerJobSolicitacoes job = new Empresa.setor.TimerJob.TimerJob.TimerJobSolicitacoes(JobName, site);

                //A cada hora exe
                SPHourlySchedule schedule = new SPHourlySchedule();
                schedule.BeginMinute = 1;
                schedule.EndMinute   = 5;

                job.Schedule = schedule;

                job.Update();
            }
            catch (Exception)
            {
                return(jobCreated);
            }
            return(jobCreated);
        }
示例#5
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWebApplication adminWebApplication = properties.Feature.Parent as SPWebApplication;

            foreach (SPJobDefinition job in adminWebApplication.JobDefinitions)
            {
                if (job.Name == tJobName)
                {
                    job.Delete();
                }
            }

            if (((SPWebApplication)properties.Feature.Parent).IsAdministrationWebApplication)
            {
                Nauplius.ADLDS.UserProfiles.ADLDSImportJob newTimerJob = new Nauplius.ADLDS.UserProfiles.ADLDSImportJob(tJobName, adminWebApplication);

                SPHourlySchedule jobSchedule = new SPHourlySchedule();
                jobSchedule.BeginMinute = 0;
                jobSchedule.EndMinute   = 59;
                newTimerJob.Schedule    = jobSchedule;
                newTimerJob.Update();
            }
        }
        static void AddCleanupTimerJob(SPSite site, SPWebApplication webApplication)
        {
            // Remove job if it exists.
            RemoveCleanupTimerJob(webApplication);

            // Create the job.
            var job = new CleanupLogListTimerJob(CleanupLogListTimerJob.JobName, webApplication);

            var schedule = new SPHourlySchedule();
            schedule.BeginMinute = 0;
            schedule.EndMinute = 59;
            job.Schedule = schedule;
            job.Update();

            var settings = new CleanupLogListTimerJobSettings(webApplication, Guid.NewGuid());
            settings.ListName = LogList.ListName;
            settings.SiteCollectionId = site.ID;
            settings.SiteId = site.RootWeb.ID;

            settings.Update(true);

            ULSLog.LogMessage("Sucessfully added settings and timer job to Web Application.");
        }