Пример #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 DeleteJob(long jobId)
        {
            string returnMessage = string.Format("Could not delete job {0}.", jobId);

            try
            {
                using (AccessPointClient client = new AccessPointClient())
                {
                    DeleteJobResponse response = client.DeleteJob(new DeleteJobRequest
                    {
                        JobId = jobId,
                    });
                    if (response.Success)
                    {
                        returnMessage = string.Format("Successfully deleted job {0}.", jobId);
                    }
                }
            }
            catch (Exception ex)
            {
                returnMessage += "<br /><br />" + ex.Message;
            }
            return(returnMessage);
        }