Exemplo n.º 1
0
        internal static OutputQueue DisableJob(SPJobDefinition job)
        {
            var outputQueue = new OutputQueue();

            if (job == null)
            {
                return(outputQueue);
            }

            outputQueue.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, UserDisplay.DisableJob, string.IsNullOrEmpty(job.DisplayName) ? job.Name : job.DisplayName));

            try
            {
                job.IsDisabled = true;
                job.Update();
            }
            catch (SPUpdatedConcurrencyException)
            { }
            catch (Exception exception)
            {
                outputQueue.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, Exceptions.DisableJobsUnableToDisableError, job.DisplayName, exception.Message), OutputType.Error, null, exception);
            }

            outputQueue.Add(UserDisplay.DisableJobComplete);

            return(outputQueue);
        }
Exemplo n.º 2
0
        private void ConfigurateTimerJob(SPJobDefinition job)
        {
            var schedule = new SPDailySchedule();
            schedule.BeginHour = 2;
            schedule.BeginMinute = 30;
            schedule.EndHour = 2;
            schedule.EndMinute = 45;

            job.Schedule = schedule;
            job.Update();
        }
Exemplo n.º 3
0
    public void DisableButton_Click(object sender, EventArgs e)
    {
        SPJobDefinition jobDefinition = GetJobDefinition();

        if (jobDefinition != null)
        {
            jobDefinition.IsDisabled = DisableButton.Text != "Enable";
            jobDefinition.Update();
            SPUtility.Redirect(SPContext.Current.Web.Url + "/_admin/operations.aspx", SPRedirectFlags.DoNotEncodeUrl,
                               HttpContext.Current);
        }
    }
Exemplo n.º 4
0
        internal static OutputQueue EnableJob(SPJobDefinition job)
        {
            var outputQueue = new OutputQueue();

            if (job == null)
            {
                return(outputQueue);
            }

            outputQueue.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, UserDisplay.EnableJob, string.IsNullOrEmpty(job.DisplayName) ? job.Name : job.DisplayName));
            try
            {
                job.IsDisabled = false;
                job.Update();
            }
            catch (SPUpdatedConcurrencyException)
            { }
            outputQueue.Add(UserDisplay.EnableJobComplete);

            return(outputQueue);
        }
Exemplo n.º 5
0
    public void SubmitButton_Click(object sender, EventArgs e)
    {
        SPJobDefinition jobDefinition = GetJobDefinition();

        if (jobDefinition != null)
        {
            string     str      = ScheduleField.Value;
            SPSchedule schedule = null;
            string     str2     = str;
            if (str2 != null)
            {
                if (!(str2 == "Minutes"))
                {
                    if (str2 == "Hourly")
                    {
                        schedule = BuildHourlySchedule();
                    }
                    else if (str2 == "Daily")
                    {
                        schedule = BuildDailySchedule();
                    }
                    else if (str2 == "Weekly")
                    {
                        schedule = BuildWeeklySchedule();
                    }
                    else if (str2 == "Monthly")
                    {
                        schedule = BuildMonthlySchedule();
                    }
                    else if (str2 == "Yearly")
                    {
                        schedule = BuildYearlySchedule();
                    }
                }
                else
                {
                    schedule = BuildMinuteSchedule();
                }
            }
            bool flag = true;
            if ((jobDefinition.Schedule != null) && jobDefinition.Schedule.Equals(schedule))
            {
                flag = false;
            }
            if (flag)
            {
                jobDefinition.Schedule = schedule;
                if (jobDefinition.IsDisabled)
                {
                    jobDefinition.IsDisabled = false;
                }
                jobDefinition.Update();
            }
            var child =
                WebAppSelector.CurrentItem.GetChild <JobSettings>(jobDefinition.Name);
            if (child == null)
            {
                child = new JobSettings(jobDefinition.Name, WebAppSelector.CurrentItem,
                                        Guid.NewGuid());
            }
            else
            {
                child.SiteCollectionsEnabled.Clear();
            }
            if (SomeSiteCollectionsRadioButton.Checked)
            {
                foreach (RepeaterItem item in SiteCollectionRepeater.Items)
                {
                    var box = item.FindControl("SiteCollectionCheckBox") as CheckBox;
                    if ((box != null) && box.Checked)
                    {
                        var label = item.FindControl("SiteCollectionIDLabel") as Label;
                        if (label != null)
                        {
                            var guid = new Guid(label.Text);
                            child.SiteCollectionsEnabled.Add(guid);
                        }
                    }
                }
            }
            child.Update();
        }
        SPUtility.Redirect(SPContext.Current.Web.Url + "/_admin/operations.aspx", SPRedirectFlags.DoNotEncodeUrl,
                           HttpContext.Current);
    }