Exemple #1
0
        public JobRequest MapHourlyJobRequest(HourlyJobRequest request)
        {
            return(new JobRequest()
            {
                JobName = "hourly_" + request.Controller + "_" + request.Action + "_" + "d0" + "h0" + "m" + request.Minute,

                Action = request.Action,
                Controller = request.Controller,
                Day = 0,
                Hour = 0,
                Minute = request.Minute,
                ServiceUrl = request.ServiceUrl
            });
        }
        public JobReponse CreateHourlyJob(HourlyJobRequest request)
        {
            JobRequest jobRequest = jobRequestMapper.MapHourlyJobRequest(request);
            JobReponse response   = new JobReponse();

            if (!DoesJobExist(jobRequest.JobName))
            {
                RecurringJob.AddOrUpdate(recurringJobId: jobRequest.JobName.ToLower(),
                                         methodCall: () => _jobRepo.CallWebServiceMethod(jobRequest.ServiceUrl, jobRequest.Controller, jobRequest.Action),
                                         cronExpression: Cron.Hourly(jobRequest.Minute),
                                         timeZone: null,
                                         queue: "hourly"
                                         );
                response.Result = "Job Added";
            }
            else
            {
                response.Result = "Job Already Exists : " + jobRequest.JobName;
            }
            return(response);
        }
 public JobReponse CreateAHourlyJob([FromBody] HourlyJobRequest dailyJobRequest)
 {
     return(_jobService.CreateHourlyJob(dailyJobRequest));
 }