<commit_before>#region Copyright
// 
// DotNetNuke - http://www.dotnetnuke.com
// Copyright (c) 2002-2014
// by DotNetNuke Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
#endregion
#region Usings

using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;

using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Host;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Framework;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using DotNetNuke.Services.Scheduling;
using DotNetNuke.UI.Skins.Controls;
using DotNetNuke.UI.Utilities;
using Globals = DotNetNuke.Common.Globals;

#endregion

namespace DotNetNuke.Modules.Admin.Scheduler
{

    /// <summary>
    /// The EditSchedule PortalModuleBase is used to edit the scheduled items.
    /// </summary>
    /// <remarks>
    /// </remarks>
    /// <history>
    /// 	[cnurse]	9/28/2004	Updated to reflect design changes for Help, 508 support
    ///                       and localisation
    /// </history>
    public partial class EditSchedule : PortalModuleBase, IActionable
    {

        #region IActionable Members

        public ModuleActionCollection ModuleActions
        {
            get
            {
                var actionCollection = new ModuleActionCollection
                                  {
                                      {
                                          GetNextActionID(), Localization.GetString(ModuleActionType.ContentOptions, LocalResourceFile), ModuleActionType.AddContent, "", "icon_scheduler_16px.gif",
                                          EditUrl("", "", "Status"), false, SecurityAccessLevel.Host, true, false
                                          }
                                  };
                if (Request.QueryString["ScheduleID"] != null)
                {
                    var scheduleID = Convert.ToInt32(Request.QueryString["ScheduleID"]);
                    actionCollection.Add(GetNextActionID(),
                                Localization.GetString("ScheduleHistory.Action", LocalResourceFile),
                                ModuleActionType.AddContent,
                                "",
                                "icon_profile_16px.gif",
                                EditUrl("ScheduleID", scheduleID.ToString(), "History"),
                                false,
                                SecurityAccessLevel.Host,
                                true,
                                false);
                }
                return actionCollection;
            }
        }

        #endregion

        #region Private Methods

        private void BindData()
        {
            if (Request.QueryString["ScheduleID"] != null)
            {
                ViewState["ScheduleID"] = Request.QueryString["ScheduleID"];
                ScheduleItem scheduleItem = SchedulingProvider.Instance().GetSchedule(Convert.ToInt32(Request.QueryString["ScheduleID"]));
                txtFriendlyName.Text = scheduleItem.FriendlyName;
                txtType.Enabled = false;
                txtType.Text = scheduleItem.TypeFullName;
                chkEnabled.Checked = scheduleItem.Enabled;
                if (!Null.IsNull(scheduleItem.ScheduleStartDate))
                {
                    startScheduleDatePicker.SelectedDate = scheduleItem.ScheduleStartDate;
                }
                txtTimeLapse.Text = Convert.ToString(scheduleItem.TimeLapse);
                if (ddlTimeLapseMeasurement.FindItemByValue(scheduleItem.TimeLapseMeasurement) != null)
                {
                    ddlTimeLapseMeasurement.FindItemByValue(scheduleItem.TimeLapseMeasurement).Selected = true;
                }
                txtRetryTimeLapse.Text = Convert.ToString(scheduleItem.RetryTimeLapse);
                if (ddlRetryTimeLapseMeasurement.FindItemByValue(scheduleItem.RetryTimeLapseMeasurement) != null)
                {
                    ddlRetryTimeLapseMeasurement.FindItemByValue(scheduleItem.RetryTimeLapseMeasurement).Selected = true;
                }
                if (ddlRetainHistoryNum.FindItemByValue(Convert.ToString(scheduleItem.RetainHistoryNum)) != null)
                {
                    ddlRetainHistoryNum.FindItemByValue(Convert.ToString(scheduleItem.RetainHistoryNum)).Selected = true;
                }
                else
                {
                    string scheduleItemRetainHistoryNum = scheduleItem.RetainHistoryNum.ToString();
                    ddlRetainHistoryNum.AddItem(scheduleItemRetainHistoryNum, scheduleItemRetainHistoryNum);
                    ddlRetainHistoryNum.FindItemByValue(Convert.ToString(scheduleItem.RetainHistoryNum)).Selected = true;
                }
                if (ddlAttachToEvent.FindItemByValue(scheduleItem.AttachToEvent) != null)
                {
                    ddlAttachToEvent.FindItemByValue(scheduleItem.AttachToEvent).Selected = true;
                }
                chkCatchUpEnabled.Checked = scheduleItem.CatchUpEnabled;
                txtObjectDependencies.Text = scheduleItem.ObjectDependencies;
                txtServers.Text = scheduleItem.Servers;
            }
            else
            {
                cmdDelete.Visible = false;
                cmdRun.Visible = false;
                txtType.Enabled = true;
            }
        }

        private ScheduleItem CreateScheduleItem()
        {
            var scheduleItem = new ScheduleItem();
            scheduleItem.TypeFullName = txtType.Text;
            scheduleItem.FriendlyName = txtFriendlyName.Text;
            //DNN-4964 - values for time lapse and retry frequency can't be set to 0, -1 or left empty (client side validation has been added)
            scheduleItem.TimeLapse = Convert.ToInt32(txtTimeLapse.Text);
            scheduleItem.TimeLapseMeasurement = ddlTimeLapseMeasurement.SelectedItem.Value;
            scheduleItem.RetryTimeLapse = Convert.ToInt32(txtRetryTimeLapse.Text);
            scheduleItem.RetryTimeLapseMeasurement = ddlRetryTimeLapseMeasurement.SelectedItem.Value;<commit_msg>CONTENT-2582 - There is a comma before the first server name in Run on Servers from Host - Schedule Cleaned up the Servers data before showing on UI<commit_after>#region Copyright
// 
// DotNetNuke - http://www.dotnetnuke.com
// Copyright (c) 2002-2014
// by DotNetNuke Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
#endregion
#region Usings

using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;

using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Host;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Framework;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using DotNetNuke.Services.Scheduling;
using DotNetNuke.UI.Skins.Controls;
using DotNetNuke.UI.Utilities;
using Globals = DotNetNuke.Common.Globals;

#endregion

namespace DotNetNuke.Modules.Admin.Scheduler
{

    /// <summary>
    /// The EditSchedule PortalModuleBase is used to edit the scheduled items.
    /// </summary>
    /// <remarks>
    /// </remarks>
    /// <history>
    /// 	[cnurse]	9/28/2004	Updated to reflect design changes for Help, 508 support
    ///                       and localisation
    /// </history>
    public partial class EditSchedule : PortalModuleBase, IActionable
    {

        #region IActionable Members

        public ModuleActionCollection ModuleActions
        {
            get
            {
                var actionCollection = new ModuleActionCollection
                                  {
                                      {
                                          GetNextActionID(), Localization.GetString(ModuleActionType.ContentOptions, LocalResourceFile), ModuleActionType.AddContent, "", "icon_scheduler_16px.gif",
                                          EditUrl("", "", "Status"), false, SecurityAccessLevel.Host, true, false
                                          }
                                  };
                if (Request.QueryString["ScheduleID"] != null)
                {
                    var scheduleID = Convert.ToInt32(Request.QueryString["ScheduleID"]);
                    actionCollection.Add(GetNextActionID(),
                                Localization.GetString("ScheduleHistory.Action", LocalResourceFile),
                                ModuleActionType.AddContent,
                                "",
                                "icon_profile_16px.gif",
                                EditUrl("ScheduleID", scheduleID.ToString(), "History"),
                                false,
                                SecurityAccessLevel.Host,
                                true,
                                false);
                }
                return actionCollection;
            }
        }

        #endregion

        #region Private Methods

        private void BindData()
        {
            if (Request.QueryString["ScheduleID"] != null)
            {
                ViewState["ScheduleID"] = Request.QueryString["ScheduleID"];
                ScheduleItem scheduleItem = SchedulingProvider.Instance().GetSchedule(Convert.ToInt32(Request.QueryString["ScheduleID"]));
                txtFriendlyName.Text = scheduleItem.FriendlyName;
                txtType.Enabled = false;
                txtType.Text = scheduleItem.TypeFullName;
                chkEnabled.Checked = scheduleItem.Enabled;
                if (!Null.IsNull(scheduleItem.ScheduleStartDate))
                {
                    startScheduleDatePicker.SelectedDate = scheduleItem.ScheduleStartDate;
                }
                txtTimeLapse.Text = Convert.ToString(scheduleItem.TimeLapse);
                if (ddlTimeLapseMeasurement.FindItemByValue(scheduleItem.TimeLapseMeasurement) != null)
                {
                    ddlTimeLapseMeasurement.FindItemByValue(scheduleItem.TimeLapseMeasurement).Selected = true;
                }
                txtRetryTimeLapse.Text = Convert.ToString(scheduleItem.RetryTimeLapse);
                if (ddlRetryTimeLapseMeasurement.FindItemByValue(scheduleItem.RetryTimeLapseMeasurement) != null)
                {
                    ddlRetryTimeLapseMeasurement.FindItemByValue(scheduleItem.RetryTimeLapseMeasurement).Selected = true;
                }
                if (ddlRetainHistoryNum.FindItemByValue(Convert.ToString(scheduleItem.RetainHistoryNum)) != null)
                {
                    ddlRetainHistoryNum.FindItemByValue(Convert.ToString(scheduleItem.RetainHistoryNum)).Selected = true;
                }
                else
                {
                    string scheduleItemRetainHistoryNum = scheduleItem.RetainHistoryNum.ToString();
                    ddlRetainHistoryNum.AddItem(scheduleItemRetainHistoryNum, scheduleItemRetainHistoryNum);
                    ddlRetainHistoryNum.FindItemByValue(Convert.ToString(scheduleItem.RetainHistoryNum)).Selected = true;
                }
                if (ddlAttachToEvent.FindItemByValue(scheduleItem.AttachToEvent) != null)
                {
                    ddlAttachToEvent.FindItemByValue(scheduleItem.AttachToEvent).Selected = true;
                }
                chkCatchUpEnabled.Checked = scheduleItem.CatchUpEnabled;
                txtObjectDependencies.Text = scheduleItem.ObjectDependencies;
                txtServers.Text = scheduleItem.Servers.Trim(',');
            }
            else
            {
                cmdDelete.Visible = false;
                cmdRun.Visible = false;
                txtType.Enabled = true;
            }
        }

        private ScheduleItem CreateScheduleItem()
        {
            var scheduleItem = new ScheduleItem();
            scheduleItem.TypeFullName = txtType.Text;
            scheduleItem.FriendlyName = txtFriendlyName.Text;
            //DNN-4964 - values for time lapse and retry frequency can't be set to 0, -1 or left empty (client side validation has been added)
            scheduleItem.TimeLapse = Convert.ToInt32(txtTimeLapse.Text);
            scheduleItem.TimeLapseMeasurement = ddlTimeLapseMeasurement.SelectedItem.Value;
            scheduleItem.RetryTimeLapse = Convert.ToInt32(txtRetryTimeLapse.Text);
            scheduleItem.RetryTimeLapseMeasurement = ddlRetryTimeLapseMeasurement.SelectedItem.Value;
{'fraction_non_alphanumeric': 0.07550669872895913, 'fraction_numerical': 0.005221573342493988, 'mean_word_length': 2.009925558312655, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2367089', 'n_tokens_mistral': 3693, 'n_tokens_neox': 3453, 'n_words': 824}