예제 #1
0
 public JobRequest MapWeeklyJobRequest(WeeklyJobRequest request)
 {
     return(new JobRequest()
     {
         JobName = "weekly_" + request.Controller + "_" + request.Action + "_" + "d" + request.Day + "h" + request.Hour + "m" + request.Minute,
         Action = request.Action,
         Controller = request.Controller,
         Day = request.Day,
         Hour = request.Hour,
         Minute = request.Minute,
         ServiceUrl = request.ServiceUrl
     });
 }
예제 #2
0
        public JobReponse CreateWeeklyJob(WeeklyJobRequest request)
        {
            JobRequest jobRequest = jobRequestMapper.MapWeeklyJobRequest(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.Weekly(jobRequest.Day, jobRequest.Hour, jobRequest.Minute),
                                         timeZone: null,
                                         queue: "weekly"
                                         );
                response.Result = "Job Added";
            }
            else
            {
                response.Result = "Job Already Exists : " + jobRequest.JobName;
            }
            return(response);
        }
 public JobReponse CreateAWeeklyJob([FromBody] WeeklyJobRequest dailyJobRequest)
 {
     return(_jobService.CreateWeeklyJob(dailyJobRequest));
 }