コード例 #1
0
        public async Task <IActionResult> InsertAsync(InsertOptimizationRequestViewModel dto)
        {
            var Status = false;
            var Result = new Res();

            await Task.Run(() => _optimizationEngineServices.Insert(dto, out Status));

            var cronType = GetCronFromRecurringType(dto.RecurringSchedule);

            RecurringJob.AddOrUpdate(_optimizationEngineServices.GetIdLasted().Id.ToString(),
                                     () => _optimizationEngine.OptimizeDeliveries(_optimizationEngineServices.GetIdLasted().Id), cronType);

            if (Status)
            {
                Result.Status     = true;
                Result.Message    = MesssageContant.SAVE_SUCCESS;
                Result.StatusCode = HttpStatusCode.OK;
            }
            else
            {
                Result.Data       = null;
                Result.Status     = Status;
                Result.Message    = MesssageContant.SAVE_FAIL;
                Result.StatusCode = HttpStatusCode.InternalServerError;
            }
            return(Ok(Result));
        }
コード例 #2
0
        public void ProcessOptimizationRequest(OptimizationRequest newOptimizationRequest)
        {
            var scheduledDeliveries = _optiEngine.OptimizeDeliveries(newOptimizationRequest.ID);

            _uof.DeliverySchedule.AddRange(scheduledDeliveries);
            _uof.SaveChanges();
        }
コード例 #3
0
        public ActionResult Create(OptimizationRequest newOptimizationRequest)
        {
            if (ModelState.IsValid)
            {
                _uof.OptimizationRequests.Add(newOptimizationRequest);
                _uof.SaveChanges();

                var cronType = GetCronFromRecurringType(newOptimizationRequest.RecurringSchedule);
                RecurringJob.AddOrUpdate(newOptimizationRequest.ID.ToString(),
                                         () => _optiEngine.OptimizeDeliveries(new OptimizeDeliveriesRequest()
                {
                    RequestID = newOptimizationRequest.ID, ScheduleDate = newOptimizationRequest.RequestDate
                }),
                                         cronType);

                return(RedirectToAction("Index"));
            }

            return(View(newOptimizationRequest));
        }
コード例 #4
0
        public ActionResult Create(OptimizationRequest newOptimizationRequest)
        {
            if (ModelState.IsValid)
            {
                _uof.OptimizationRequests.Add(newOptimizationRequest);
                _uof.SaveChanges();

                var id = BackgroundJob.Enqueue(() => _optiEngine.OptimizeDeliveries(newOptimizationRequest.ID));

                return(RedirectToAction("Index"));
            }

            return(View(newOptimizationRequest));
        }
        public async Task <IActionResult> InsertEnqueueAsync(InsertOptimizationRequestViewModel dto)
        {
            var Status = false;
            var Result = new Res();

            await Task.Run(() => _optimizationEngineServices.Insert(dto, out Status));

            BackgroundJob.Enqueue(() => _optimizationEngine.OptimizeDeliveries(_optimizationEngineServices.GetIdLasted().Id));

            if (Status)
            {
                Result.Status     = true;
                Result.Message    = MesssageContant.SAVE_SUCCESS;
                Result.StatusCode = HttpStatusCode.OK;
            }
            else
            {
                Result.Data       = null;
                Result.Status     = Status;
                Result.Message    = MesssageContant.SAVE_FAIL;
                Result.StatusCode = HttpStatusCode.InternalServerError;
            }
            return(Ok(Result));
        }
コード例 #6
0
        public ActionResult Create(OptimizationRequest newOptimizationRequest)
        {
            if (ModelState.IsValid)
            {
                _uof.OptimizationRequests.Add(newOptimizationRequest);
                _uof.SaveChanges();

                var id = _backgroundJobClient.Schedule(() => _optiEngine.OptimizeDeliveries(newOptimizationRequest.ID),
                                                       TimeSpan.FromMinutes(newOptimizationRequest.OptimizeAfterMinuntes));

                return(RedirectToAction("Index"));
            }

            return(View(newOptimizationRequest));
        }
コード例 #7
0
 public void ProcessOptimizationRequest(OptimizationRequest newOptimizationRequest)
 {
     BackgroundJob.Enqueue(() => _optiEngine.OptimizeDeliveries(newOptimizationRequest.ID));
 }