public WorkItemUpdateResponse Update(WorkItemUpdateRequest request) { try { return(WorkItemService.Instance.Update(request)); } catch (Exception e) { Platform.Log(LogLevel.Error, e); var message = SR.ExceptionErrorProcessingUpdate; var exceptionMessage = String.Format("{0}\nDetail:{1}", message, e.Message); throw new WorkItemServiceException(exceptionMessage); } }
public WorkItemUpdateResponse Update(WorkItemUpdateRequest request) { return(Channel.Update(request)); }
public WorkItemUpdateResponse Update(WorkItemUpdateRequest request) { var response = new WorkItemUpdateResponse(); var workItem = IoC.Get <IWorkItemOperation>().GetWorkItem(request.Identifier); if (workItem == null) { response.Item = null; return(response); } var deleted = false; if (request.Delete.HasValue && request.Delete.Value) { if (workItem.Status != WorkItemStatusEnum.InProgress) { workItem.Status = WorkItemStatusEnum.Deleted; deleted = true; // If StudyDelete we're removing, "undelete" the study // CheckDeleteStudyCanceled(context, workItem); } } if (!deleted) { if (request.ExpirationTime.HasValue) { workItem.ExpirationTime = request.ExpirationTime.Value; } if (request.Priority.HasValue) { workItem.Priority = request.Priority.Value; } if (request.Status.HasValue && workItem.Status != WorkItemStatusEnum.InProgress) { workItem.Status = request.Status.Value; if (request.Status.Value == WorkItemStatusEnum.Canceled) { workItem.DeleteTime = DateTime.Now.AddMinutes(WorkItemServiceSettings.Default.DeleteDelayMinutes); } else if (request.Status.Value == WorkItemStatusEnum.Pending) { workItem.ScheduledTime = DateTime.Now; workItem.FailureCount = 0; } // Cache the UserIdentityContext for later use by the shred //if (workItem.Request.WorkItemType.Equals(ImportFilesRequest.WorkItemTypeString) && // request.Status.Value == WorkItemStatusEnum.Pending) // UserIdentityCache.Put(workItem.Oid, UserIdentityContext.CreateFromCurrentThreadPrincipal()); } if (request.ProcessTime.HasValue) { workItem.ProcessTime = request.ProcessTime.Value; } // Cancel if (request.Cancel.HasValue && request.Cancel.Value) { if (workItem.Progress == null || workItem.Progress.IsCancelable) { if (workItem.Status.Equals(WorkItemStatusEnum.Idle) || workItem.Status.Equals(WorkItemStatusEnum.Pending)) { workItem.Status = WorkItemStatusEnum.Canceled; // If StudyDelete we're removing, "undelete" the study // CheckDeleteStudyCanceled(context, workItem); } else if (workItem.Status.Equals(WorkItemStatusEnum.InProgress)) { // Abort the WorkItem WorkItemProcessor.Instance.Cancel(workItem.Oid); } } } // Pause if (request.Pause.HasValue && request.Pause.Value) { if (workItem.Progress == null || workItem.Progress.IsPauseable) { if (workItem.Status.Equals(WorkItemStatusEnum.Idle) || workItem.Status.Equals(WorkItemStatusEnum.Pending)) { workItem.Status = WorkItemStatusEnum.Pause; } else if (workItem.Status.Equals(WorkItemStatusEnum.InProgress)) { // Pause the WorkItem WorkItemProcessor.Instance.Pause(workItem.Oid); } } } IoC.Get <IWorkItemOperation>().SaveWorkItem(workItem); response.Item = WorkItemDataHelper.FromWorkItem(workItem); } WorkItemPublishSubscribeHelper.PublishWorkItemChanged(WorkItemsChangedEventType.Update, response.Item); return(response); }