Exemple #1
0
        public async Task <IActionResult> Create(ScheduleConfigViewModel viewModel)
        {
            if (viewModel != null)
            {
                // Binding to a nullable enum will cause a ModelState error
                ViewData.ModelState.Remove(nameof(viewModel.ScheduleInterval));

                if (!ViewData.ModelState.IsValid)
                {
                    return(View(viewModel));
                }

                ScheduleRun schedule = new ScheduleRun
                {
                    ScheduleType = (ScheduleType)viewModel.ScheduleType,
                    RunTime      = viewModel.Date.UtcFromTimeZoneTime(),
                    IsRecurring  = viewModel.ScheduleInterval.HasValue,
                    Interval     = (int?)viewModel.ScheduleInterval
                };

                await _apiClient.CreateScheduleRun(schedule);
            }

            return(RedirectToAction("Index"));
        }
        protected virtual void Parameters_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            ScheduleRun.SetProcessDelegate <APScheduleProcess>(this, (ScheduleRun.Parameters)e.Row, Schedule_List);
        }
Exemple #3
0
        private static ScheduleConfigViewModel MapToScheduleConfigViewModel(ScheduleRun schedule)
        {
            ScheduleConfigViewModel viewModel = new ScheduleConfigViewModel
            {
                Id            = schedule.Id,
                RunTime       = schedule.RunTime.UtcToTimeZoneTime(),
                Interval      = schedule.Interval.HasValue ? TimeSpan.FromMinutes(schedule.Interval.Value).Humanize().Titleize() : "-",
                IsRecurring   = schedule.IsRecurring,
                ScheduleType  = (ScheduleJobType)schedule.ScheduleType,
                LastRunStatus = schedule.LastRunStatus
            };

            if (Enum.TryParse <ScheduleInterval>(schedule.Interval.ToString(), out var scheduleInterval) && Enum.IsDefined(typeof(ScheduleInterval), scheduleInterval))
            {
                viewModel.ScheduleInterval = scheduleInterval;
            }

            return(viewModel);
        }
Exemple #4
0
 public async Task CreateScheduleRun(ScheduleRun scheduleRun)
 {
     await _connection.ExecuteAsync(
         @"INSERT ScheduleRuns (RunTime, Interval, IsRecurring, ScheduleType) 
                        VALUES (@runTime, @interval, @isRecurring, @scheduleType)", scheduleRun);
 }
Exemple #5
0
        public async Task <IActionResult> Create([FromBody] ScheduleRun scheduleRun)
        {
            await _scheduleRepository.CreateScheduleRun(scheduleRun);

            return(Ok());
        }
 public async Task <object> CreateScheduleRun(ScheduleRun schedule)
 {
     return(await Put <ScheduleRun, object>($"api/v1/schedule/create", schedule));
 }