/// <summary>
        /// Raises the load event
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            _scheduledPublishRepo = new ScheduledPublishRepo();

            if (!Context.ClientPage.IsEvent)
            {
                ServerTime.Text = Constants.CURREN_TIME_ON_SERVER_TEXT + DateTime.Now.ToString(_culture);
                RenderAllSchedules();
            }

            base.OnLoad(e);
        }
        public void Process(GetContentEditorWarningsArgs args)
        {
            Item item = args.Item;
            Assert.IsNotNull(item, "item");

            ScheduledPublishRepo scheduledPublishRepo = new ScheduledPublishRepo();

            IEnumerable<PublishSchedule> schedulesForCurrentItem = scheduledPublishRepo.GetSchedules(item.ID);

            if (schedulesForCurrentItem.Any())
            {
                GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add();
                warning.Icon = "Applications/32x32/information2.png";
                warning.Text = "This item has been scheduled for publish.";
                warning.IsExclusive = false;
            }
        }
        /// <summary>
        /// Start point of the command
        /// </summary>
        /// <param name="items">Passed items</param>
        /// <param name="command">Passed command</param>
        /// <param name="schedule">Passed schedule item</param>
        public void Run(Item[] items, CommandItem command, ScheduleItem schedule)
        {
            Log.Info("Scheduled Publish: started", this);

            _scheduledPublishRepo = new ScheduledPublishRepo();

            Stopwatch commandStopwatch = new Stopwatch();
            commandStopwatch.Start();

            //Publish all scheduled for the last hour
            DateTime publishToDate = DateTime.Now;
            DateTime publishFromDate = publishToDate.AddHours(-1);
            PublishSchedules(publishFromDate, publishToDate);

            //Alerts for failed schedules 2 hours ago
            DateTime alertToDate = publishFromDate.AddHours(-1).AddSeconds(-1);
            DateTime alertFromDate = publishFromDate.AddHours(-2);
            AlertForFailedSchedules(alertFromDate, alertToDate);

            _scheduledPublishRepo.CleanBucket();
            commandStopwatch.Stop();
            Log.Info("Scheduled Publish: Total Run " + commandStopwatch.ElapsedMilliseconds, this);
        }
        /// <summary>
        /// Raises the load event
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");

            _scheduledPublishRepo = new ScheduledPublishRepo();

            if (!Context.ClientPage.IsEvent)
            {
                if (Unpublish)
                {
                    PublishModePanel.Visible = false;
                    ScheduleLanguages.Visible = false;
                    BuildUnpublishTitles();
                }

                BuildExistingSchedules();
                BuildPublishingTargets();
                BuildLanguages();

                ServerTime.Text = Constants.CURREN_TIME_ON_SERVER_TEXT + DateTime.Now.ToString(_culture);
                SmartPublish.Checked = true;
            }

            base.OnLoad(e);
        }