示例#1
0
        public bool SaveData()
        {
            if (!ValidateData())
                return false;

            var settings = new TaskSqlSettings();
            var item = new TaskSqlSetting();
            //html
            item.Enabled = chbEnabledHtml.Checked;
            item.JobType = typeof(GenerateHtmlMapJob).ToString();
            item.TimeInterval = txtTimeIntervalHtml.Text.TryParseInt();
            item.TimeType = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeHtml.SelectedValue, true);
            if (item.TimeType == TimeIntervalType.Days)
            {
                item.TimeHours = txtHoursHtml.Text.TryParseInt();
                item.TimeMinutes = txtMinutesHtml.Text.TryParseInt();
            }
            settings.Add(item);
            //xml
            item = new TaskSqlSetting();
            item.Enabled = chbEnabledXml.Checked;
            item.JobType = typeof(GenerateXmlMapJob).ToString();
            item.TimeInterval = txtTimeIntervalXml.Text.TryParseInt();
            item.TimeType = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeXml.SelectedValue, true);
            if (item.TimeType == TimeIntervalType.Days)
            {
                item.TimeHours = txtHoursXml.Text.TryParseInt();
                item.TimeMinutes = txtMinutesXml.Text.TryParseInt();
            }
            settings.Add(item);
            //yandex
            item = new TaskSqlSetting();
            item.Enabled = chbEnabledYandex.Checked & ShowYaMarket;
            item.JobType = typeof(GenerateYandexMarketJob).ToString();
            item.TimeInterval = txtTimeIntervalYandex.Text.TryParseInt();
            item.TimeType = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeYandex.SelectedValue, true);
            if (item.TimeType == TimeIntervalType.Days)
            {
                item.TimeHours = txtHoursYandex.Text.TryParseInt();
                item.TimeMinutes = txtMinutesYandex.Text.TryParseInt();
            }
            settings.Add(item);
            TaskSqlSettings.TaskSettings = settings;
            TaskManager.TaskManagerInstance().ManagedTask(settings);
            LoadData();
            return true;
        }
示例#2
0
 private string GetCronString(TaskSqlSetting item)
 {
     switch (item.TimeType)
     {
         case TimeIntervalType.Days:
             return string.Format("0 {2} {1} 1/{0} * ?", item.TimeInterval, item.TimeHours, item.TimeMinutes);
         case TimeIntervalType.Hours:
             return string.Format("0 0 0/{0} * * ?", item.TimeInterval);
         case TimeIntervalType.Minutes:
             return string.Format("0 0/{0} * * * ?", item.TimeInterval);
     }
     return string.Empty;
 }
示例#3
0
    public bool SaveData()
    {
        if (!ValidateData())
        {
            return(false);
        }

        var settings = new TaskSqlSettings();
        var item     = new TaskSqlSetting();

        //html
        item.Enabled      = chbEnabledHtml.Checked;
        item.JobType      = typeof(GenerateHtmlMapJob).ToString();
        item.TimeInterval = txtTimeIntervalHtml.Text.TryParseInt();
        item.TimeType     = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeHtml.SelectedValue, true);
        if (item.TimeType == TimeIntervalType.Days)
        {
            item.TimeHours   = txtHoursHtml.Text.TryParseInt();
            item.TimeMinutes = txtMinutesHtml.Text.TryParseInt();
        }
        settings.Add(item);
        //xml
        item              = new TaskSqlSetting();
        item.Enabled      = chbEnabledXml.Checked;
        item.JobType      = typeof(GenerateXmlMapJob).ToString();
        item.TimeInterval = txtTimeIntervalXml.Text.TryParseInt();
        item.TimeType     = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeXml.SelectedValue, true);
        if (item.TimeType == TimeIntervalType.Days)
        {
            item.TimeHours   = txtHoursXml.Text.TryParseInt();
            item.TimeMinutes = txtMinutesXml.Text.TryParseInt();
        }
        settings.Add(item);
        //yandex
        item              = new TaskSqlSetting();
        item.Enabled      = chbEnabledYandex.Checked & ShowYaMarket;
        item.JobType      = typeof(GenerateYandexMarketJob).ToString();
        item.TimeInterval = txtTimeIntervalYandex.Text.TryParseInt();
        item.TimeType     = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeYandex.SelectedValue, true);
        if (item.TimeType == TimeIntervalType.Days)
        {
            item.TimeHours   = txtHoursYandex.Text.TryParseInt();
            item.TimeMinutes = txtMinutesYandex.Text.TryParseInt();
        }
        settings.Add(item);
        //Added by Evgeni. Amount update
        item              = new TaskSqlSetting();
        item.Enabled      = chbEnableAmountUpdate.Checked;
        item.JobType      = typeof(GenerateNesProductAmountUpdateJob).ToString();
        item.TimeInterval = txtTimeIntervalAmountUpdate.Text.TryParseInt();
        item.TimeType     = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeAmountUpdate.SelectedValue, true);
        if (item.TimeType == TimeIntervalType.Days)
        {
            item.TimeHours   = txtHoursAmountUpdate.Text.TryParseInt();
            item.TimeMinutes = txtMinutesAmountUpdate.Text.TryParseInt();
        }
        settings.Add(item);
        ///
        TaskSqlSettings.TaskSettings = settings;
        TaskManager.TaskManagerInstance().ManagedTask(settings);
        LoadData();
        return(true);
    }