Пример #1
0
        protected void JobsList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            long jobId;

            if (long.TryParse((string)e.CommandArgument, out jobId))
            {
                switch (e.CommandName.ToUpper())
                {
                case "RUN":
                    using (AccessPointClient accessPoint = new AccessPointClient())
                    {
                        JobData job = accessPoint.GetJobs(new GetJobsRequest
                        {
                            Skip   = 0,
                            Take   = 1,
                            JobIds = new long[] { jobId },
                        }).Jobs.FirstOrDefault();

                        if (job != null)
                        {
                            if (job.CalendarSchedule == null)
                            {
                                job.Status = JobStatus.Ready;
                                accessPoint.UpdateJob(new UpdateJobRequest {
                                    JobData = job
                                });
                            }
                            else
                            {
                                accessPoint.RunScheduledJob(new RunScheduledJobRequest {
                                    JobId = jobId
                                });
                            }
                        }
                    }
                    break;

                case "DELETE":
                    using (AccessPointClient accessPoint = new AccessPointClient())
                    {
                        accessPoint.DeleteJob(new DeleteJobRequest {
                            JobId = jobId
                        });
                    }
                    break;
                }
            }
        }
Пример #2
0
        public static string UpdateJob(string name, string description, string data, string metaData, string absoluteTimeout, string queueId, string application, string group, bool suppressHistory, bool deleteWhenDone)
        {
            try
            {
                long    jobId = GetJobIdFromQueryString();
                JobData job   = GetJob(jobId);
                if (job != null)
                {
                    job.Name        = name;
                    job.Description = description;
                    job.Data        = data;
                    job.MetaData    = metaData;
                    if (!string.IsNullOrEmpty(absoluteTimeout))
                    {
                        job.AbsoluteTimeout = TimeSpan.Parse(absoluteTimeout);
                    }
                    if (!string.IsNullOrEmpty(queueId))
                    {
                        job.QueueId = byte.Parse(queueId);
                    }
                    job.Application     = application;
                    job.Group           = group;
                    job.SuppressHistory = suppressHistory;
                    job.DeleteWhenDone  = deleteWhenDone;

                    using (AccessPointClient accessPoint = new AccessPointClient())
                    {
                        accessPoint.UpdateJob(new UpdateJobRequest {
                            JobData = job
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return(string.Empty);
        }
Пример #3
0
        public static string UpdateJob(long jobId, string uniqueId, string name, string description, string data, string metaData, string statusId, string absoluteTimeout, string queueId, string application, string group, string suppressHistory, string deleteWhenDone, SimpleSchedule schedule)
        {
            try
            {
                JobData job = GetJob(jobId);
                if (job != null)
                {
                    if (!string.IsNullOrEmpty(statusId))
                    {
                        job.Status = (JobStatus)(int.Parse(statusId));
                    }

                    job.UniqueId    = Guid.Parse(uniqueId);
                    job.Name        = name;
                    job.Description = description;
                    job.Data        = data;
                    job.MetaData    = metaData;
                    if (!string.IsNullOrEmpty(absoluteTimeout))
                    {
                        job.AbsoluteTimeout = TimeSpan.Parse(absoluteTimeout);
                    }
                    if (!string.IsNullOrEmpty(queueId))
                    {
                        job.QueueId = byte.Parse(queueId);
                    }
                    job.Application     = application;
                    job.Group           = group;
                    job.SuppressHistory = bool.Parse(suppressHistory);
                    job.DeleteWhenDone  = bool.Parse(deleteWhenDone);

                    if (schedule != null)
                    {
                        if (!schedule.StartDailyAt.HasValue)
                        {
                            schedule.StartDailyAt = new TimeSpan();
                        }
                        job.CalendarSchedule = new CalendarSchedule
                        {
                            ScheduleType = typeof(global::BackgroundWorkerService.Logic.DataModel.Scheduling.CalendarSchedule).AssemblyQualifiedName,
                            DaysOfWeek   = schedule.DaysOfWeek.ToArray(),
                            StartDailyAt = new TimeOfDay {
                                Hour = schedule.StartDailyAt.Value.Hours, Minute = schedule.StartDailyAt.Value.Minutes, Second = schedule.StartDailyAt.Value.Seconds
                            },
                            RepeatInterval = schedule.RepeatInterval,
                            EndDateTime    = null,
                            StartDateTime  = !string.IsNullOrEmpty(schedule.StartDateTime) ? DateTime.ParseExact(schedule.StartDateTime, "dd-MM-yyyy HH:mm:ss", CultureInfo.CurrentCulture) : job.CalendarSchedule.StartDateTime,
                        };
                    }
                    else
                    {
                        job.CalendarSchedule = null;
                    }

                    using (AccessPointClient accessPoint = new AccessPointClient())
                    {
                        accessPoint.UpdateJob(new UpdateJobRequest {
                            JobData = job
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
            return(string.Empty);
        }