public void Delete(Elastic.Models.ServiceElastic serviceElastic)
        {
            if (serviceElastic.Status == (int)ServiceStatusEnum.Active)
            {
                Deactivate(serviceElastic.Id);
            }
            if (serviceElastic.Status == (int)ServiceStatusEnum.Busy)
            {
                var actualProcessId = serviceElastic.ProcessIdList.FirstOrDefault(pid => GlobalStore.Processes.IsExist(pid));
                if (actualProcessId != null)
                {
                    processHandler.Cancel(actualProcessId);
                    while (GlobalStore.Processes.IsExist(actualProcessId))
                    {
                    }
                }
            }
            if (serviceElastic.Status == (int)ServiceStatusEnum.Prepared)
            {
            }

            var directoryPath = string.Format("{0}/{1}", _dictionaryRootPath, serviceElastic.Id);

            IOHelper.SafeDeleteDictionary(directoryPath, true);
        }
        public IActionResult Cancel(string id)
        {
            var process = processQuery.Get(id);

            if (process == null)
            {
                return(new HttpStatusCodeWithErrorResult(StatusCodes.Status404NotFound,
                                                         string.Format(ProcessResources.ProcessWithId_0_DoesNotFound, id)));
            }

            if (process.Status != (int)ProcessStatusEnum.InProgress)
            {
                return(new HttpStatusCodeWithErrorResult(StatusCodes.Status400BadRequest, ProcessResources.InvalidStatusOnlyProcessesWithInProgressCanBeCancelled));
            }
            processHandler.Cancel(process.Id);
            return(new StatusCodeResult(StatusCodes.Status202Accepted));
        }
Beispiel #3
0
 public void Delete(ServiceElastic serviceElastic)
 {
     if (serviceElastic.Status == (int)ServiceStatusEnum.Active)
     {
         Deactivate(serviceElastic.Id);
     }
     if (serviceElastic.Status == (int)ServiceStatusEnum.Busy)
     {
         var actualProcessId = serviceElastic.ProcessIdList.FirstOrDefault(pid => GlobalStore.Processes.IsExist(pid));
         if (actualProcessId != null)
         {
             processHandler.Cancel(actualProcessId);
             while (GlobalStore.Processes.IsExist(actualProcessId))
             {
             }
         }
     }
     if (serviceElastic.Status == (int)ServiceStatusEnum.Prepared)
     {
     }
 }