Пример #1
0
        public void FrequencyType_SelectedIndexChanged(object sender, EventArgs e)
        {
            var frequencyType = EFrequencyTypeUtils.GetEnumType(FrequencyType.SelectedValue);

            PlaceHolder_NotPeriod.Visible            = true;
            PlaceHolder_PeriodIntervalMinute.Visible = false;
            if (frequencyType == EFrequencyType.Month)
            {
                StartWeekday.Enabled = false;
                StartDay.Enabled     = StartHour.Enabled = true;
            }
            else if (frequencyType == EFrequencyType.Week)
            {
                StartDay.Enabled     = false;
                StartWeekday.Enabled = StartHour.Enabled = true;
            }
            else if (frequencyType == EFrequencyType.Day)
            {
                StartDay.Enabled  = StartWeekday.Enabled = false;
                StartHour.Enabled = true;
            }
            else if (frequencyType == EFrequencyType.Hour)
            {
                StartDay.Enabled = StartWeekday.Enabled = StartHour.Enabled = false;
            }
            else
            {
                PlaceHolder_NotPeriod.Visible            = false;
                PlaceHolder_PeriodIntervalMinute.Visible = true;

                if (frequencyType == EFrequencyType.JustInTime)
                {
                    PlaceHolder_PeriodIntervalMinute.Visible = false;
                }
            }
        }
Пример #2
0
        public List <TaskInfo> GetAllTaskInfoList()
        {
            var list = new List <TaskInfo>();

            const string sqlString = "SELECT TaskID, TaskName, IsSystemTask, PublishmentSystemID, ServiceType, ServiceParameters, FrequencyType, PeriodIntervalMinute, StartDay, StartWeekday, StartHour, IsEnabled, AddDate, LastExecuteDate, Description, OnlyOnceDate FROM siteserver_Task";

            using (var rdr = ExecuteReader(sqlString))
            {
                while (rdr.Read())
                {
                    var i    = 0;
                    var info = new TaskInfo(GetInt(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetInt(rdr, i++), EServiceTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), EFrequencyTypeUtils.GetEnumType(GetString(rdr, i++)), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetDateTime(rdr, i++), GetDateTime(rdr, i++), GetString(rdr, i++), GetDateTime(rdr, i));
                    list.Add(info);
                }
                rdr.Close();
            }
            return(list);
        }
Пример #3
0
        public List <TaskInfo> GetTaskInfoList(EServiceType serviceType, int publishmentSystemId)
        {
            var list = new List <TaskInfo>();

            const string sqlString = "SELECT TaskID, TaskName, IsSystemTask, PublishmentSystemID, ServiceType, ServiceParameters, FrequencyType, PeriodIntervalMinute, StartDay, StartWeekday, StartHour, IsEnabled, AddDate, LastExecuteDate, Description, OnlyOnceDate FROM siteserver_Task WHERE ServiceType = @ServiceType AND PublishmentSystemID = @PublishmentSystemID";

            var parms = new IDataParameter[]
            {
                GetParameter(ParmServiceType, EDataType.VarChar, 50, EServiceTypeUtils.GetValue(serviceType)),
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId)
            };

            using (var rdr = ExecuteReader(sqlString, parms))
            {
                while (rdr.Read())
                {
                    var i    = 0;
                    var info = new TaskInfo(GetInt(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetInt(rdr, i++), EServiceTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), EFrequencyTypeUtils.GetEnumType(GetString(rdr, i++)), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetDateTime(rdr, i++), GetDateTime(rdr, i++), GetString(rdr, i++), GetDateTime(rdr, i));
                    list.Add(info);
                }
                rdr.Close();
            }
            return(list);
        }
Пример #4
0
        public TaskInfo GetTaskInfo(int taskId)
        {
            TaskInfo info = null;

            var parms = new IDataParameter[]
            {
                GetParameter(ParmTaskId, EDataType.Integer, taskId)
            };

            using (var rdr = ExecuteReader(SqlSelectById, parms))
            {
                if (rdr.Read())
                {
                    var i = 0;
                    info = new TaskInfo(GetInt(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetInt(rdr, i++), EServiceTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), EFrequencyTypeUtils.GetEnumType(GetString(rdr, i++)), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetDateTime(rdr, i++), GetDateTime(rdr, i++), GetString(rdr, i++), GetDateTime(rdr, i));
                }
                rdr.Close();
            }

            return(info);
        }
Пример #5
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            var serviceParamters = new ExtendedAttributes();

            if (_serviceType == EServiceType.Create)
            {
                var taskCreateInfo = new TaskCreateInfo(string.Empty);
                taskCreateInfo.IsCreateAll         = CreateIsCreateAll.Checked;
                taskCreateInfo.ChannelIDCollection = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueArrayList(CreateChannelIDCollection));
                taskCreateInfo.CreateTypes         = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueArrayList(CreateCreateTypes));
                serviceParamters = taskCreateInfo;
            }
            else if (_serviceType == EServiceType.Gather)
            {
                var taskGatherInfo = new TaskGatherInfo(string.Empty);
                if (PublishmentSystemId != 0)
                {
                    var webGatherNames      = new ArrayList();
                    var databaseGatherNames = new ArrayList();
                    var fileGatherNames     = new ArrayList();
                    foreach (ListItem item in GatherListBox.Items)
                    {
                        if (item.Selected)
                        {
                            var gatherType = EGatherTypeUtils.GetEnumType(item.Value.Split('_')[0]);
                            var gatherName = item.Value.Substring(item.Value.Split('_')[0].Length + 1);
                            if (gatherType == EGatherType.Web && !webGatherNames.Contains(gatherName))
                            {
                                webGatherNames.Add(gatherName);
                            }
                            else if (gatherType == EGatherType.Database && !databaseGatherNames.Contains(gatherName))
                            {
                                databaseGatherNames.Add(gatherName);
                            }
                            else if (gatherType == EGatherType.File && !fileGatherNames.Contains(gatherName))
                            {
                                fileGatherNames.Add(gatherName);
                            }
                        }
                    }
                    taskGatherInfo.WebGatherNames      = TranslateUtils.ObjectCollectionToString(webGatherNames);
                    taskGatherInfo.DatabaseGatherNames = TranslateUtils.ObjectCollectionToString(databaseGatherNames);
                    taskGatherInfo.FileGatherNames     = TranslateUtils.ObjectCollectionToString(fileGatherNames);
                }
                else
                {
                    taskGatherInfo.PublishmentSystemIDCollection = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueArrayList(GatherListBox));
                }
                serviceParamters = taskGatherInfo;
            }
            else if (_serviceType == EServiceType.Backup)
            {
                var taskBackupInfo = new TaskBackupInfo(string.Empty);
                taskBackupInfo.BackupType  = EBackupTypeUtils.GetEnumType(BackupType.SelectedValue);
                taskBackupInfo.IsBackupAll = BackupIsBackupAll.Checked;
                taskBackupInfo.PublishmentSystemIDCollection = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueArrayList(BackupPublishmentSystemIDCollection));
                serviceParamters = taskBackupInfo;
            }

            if (Body.IsQueryExists("TaskID"))
            {
                try
                {
                    var taskId   = Body.GetQueryInt("TaskID");
                    var taskInfo = DataProvider.TaskDao.GetTaskInfo(taskId);
                    taskInfo.FrequencyType = EFrequencyTypeUtils.GetEnumType(FrequencyType.SelectedValue);
                    if (taskInfo.FrequencyType == EFrequencyType.Period)
                    {
                        taskInfo.PeriodIntervalMinute = TranslateUtils.ToInt(PeriodInterval.Text) * TranslateUtils.ToInt(PeriodIntervalType.SelectedValue);
                    }
                    else if (taskInfo.FrequencyType != EFrequencyType.JustInTime)
                    {
                        taskInfo.StartDay     = TranslateUtils.ToInt(StartDay.SelectedValue);
                        taskInfo.StartWeekday = TranslateUtils.ToInt(StartWeekday.SelectedValue);
                        taskInfo.StartHour    = TranslateUtils.ToInt(StartHour.SelectedValue);
                    }
                    taskInfo.Description       = Description.Text;
                    taskInfo.ServiceParameters = serviceParamters.ToString();

                    DataProvider.TaskDao.Update(taskInfo);

                    Body.AddSiteLog(PublishmentSystemId, $"修改{EServiceTypeUtils.GetText(taskInfo.ServiceType)}任务", $"任务名称:{taskInfo.TaskName}");

                    SuccessMessage("任务修改成功!");
                    isChanged = true;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "任务修改失败!");
                }
            }
            else
            {
                if (DataProvider.TaskDao.IsExists(TaskName.Text))
                {
                    FailMessage("任务添加失败,任务名称已存在!");
                }
                else
                {
                    try
                    {
                        var taskInfo = new TaskInfo();
                        taskInfo.TaskName            = TaskName.Text;
                        taskInfo.PublishmentSystemID = PublishmentSystemId;
                        taskInfo.ServiceType         = _serviceType;
                        taskInfo.FrequencyType       = EFrequencyTypeUtils.GetEnumType(FrequencyType.SelectedValue);
                        if (taskInfo.FrequencyType == EFrequencyType.Period)
                        {
                            taskInfo.PeriodIntervalMinute = TranslateUtils.ToInt(PeriodInterval.Text) * TranslateUtils.ToInt(PeriodIntervalType.SelectedValue);
                        }
                        else if (taskInfo.FrequencyType != EFrequencyType.JustInTime)
                        {
                            taskInfo.StartDay     = TranslateUtils.ToInt(StartDay.SelectedValue);
                            taskInfo.StartWeekday = TranslateUtils.ToInt(StartWeekday.SelectedValue);
                            taskInfo.StartHour    = TranslateUtils.ToInt(StartHour.SelectedValue);
                        }
                        taskInfo.Description = Description.Text;

                        taskInfo.ServiceParameters = serviceParamters.ToString();

                        taskInfo.IsEnabled       = true;
                        taskInfo.AddDate         = DateTime.Now;
                        taskInfo.OnlyOnceDate    = DateUtils.SqlMinValue;
                        taskInfo.LastExecuteDate = DateUtils.SqlMinValue;

                        DataProvider.TaskDao.Insert(taskInfo);

                        Body.AddSiteLog(PublishmentSystemId, $"添加{EServiceTypeUtils.GetText(taskInfo.ServiceType)}任务", $"任务名称:{taskInfo.TaskName}");

                        SuccessMessage("任务添加成功!");
                        isChanged = true;
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "任务添加失败!");
                    }
                }
            }

            if (isChanged)
            {
                PageUtils.CloseModalPageAndRedirect(Page, PageTask.GetRedirectUrl(PublishmentSystemId, _serviceType));
            }
        }