private void PopulateDropdownLists() { var workQueueTypes = WorkQueueTypeEnum.GetAll(); var workQueueStatuses = WorkQueueStatusEnum.GetAll(); var workQueuePriorities = WorkQueuePriorityEnum.GetAll(); if (TypeListBox.Items.Count == 0) { foreach (WorkQueueTypeEnum t in workQueueTypes) { TypeListBox.Items.Add(new ListItem(ServerEnumDescription.GetLocalizedDescription(t), t.Lookup)); } } if (StatusListBox.Items.Count == 0) { foreach (WorkQueueStatusEnum s in workQueueStatuses) { // #10784: remove Completed status filter if (s != WorkQueueStatusEnum.Completed) { StatusListBox.Items.Add(new ListItem(ServerEnumDescription.GetLocalizedDescription(s), s.Lookup)); } } } if (PriorityDropDownList.Items.Count == 0) { PriorityDropDownList.Items.Clear(); PriorityDropDownList.Items.Add(new ListItem(SR.Any, string.Empty)); foreach (WorkQueuePriorityEnum p in workQueuePriorities) { PriorityDropDownList.Items.Add(new ListItem(ServerEnumDescription.GetLocalizedDescription(p), p.Lookup)); } } }
/// <summary> /// Creates an instance of <see cref="SopInstanceImporterContext"/> to be used /// by <see cref="SopInstanceImporter"/> /// </summary> /// <param name="contextId">The ID assigned to the context. This will be used as the name of storage folder in case of duplicate.</param> /// <param name="sourceAe">Source AE title of the image(s) to be imported</param> /// <param name="partition">The <see cref="ServerPartition"/> which the image(s) will be imported to</param> /// <param name="request">An external request that triggered this operation.</param> /// <param name="priority">The priority that resulting <see cref="WorkQueue"/> will have upon insertion.</param> public SopInstanceImporterContext(string contextId, string sourceAe, ServerPartition partition, ExternalRequestQueue request = null, WorkQueuePriorityEnum priority = null) { Platform.CheckForEmptyString(contextId, "contextID"); Platform.CheckForNullReference(partition, "partition"); _contextID = contextId; _sourceAE = sourceAe; _partition = partition; _request = request; _priorityEnum = priority; }
public UpdateWorkQueueCommand(DicomMessageBase message, StudyStorageLocation location, bool duplicate, WorkQueueData data = null, WorkQueueUidData uidData = null, ExternalRequestQueue request = null, WorkQueuePriorityEnum priority = null) : base("Update/Insert a WorkQueue Entry") { Platform.CheckForNullReference(message, "Dicom Message object"); Platform.CheckForNullReference(location, "Study Storage Location"); _message = message; _storageLocation = location; _duplicate = duplicate; _data = data; _request = request; _uidData = uidData; _priority = priority; }
public void Insert(Guid Guid, short EnumX, string Lookup, string Description, string LongDescription) { var item = new WorkQueuePriorityEnum(); item.Guid = Guid; item.EnumX = EnumX; item.Lookup = Lookup; item.Description = Description; item.LongDescription = LongDescription; item.Save(UserName); }
protected override void OnInit(EventArgs e) { base.OnInit(e); CalendarExtender.Format = DateTimeFormatter.DefaultDateFormat; PriorityDropDownList.Items.Clear(); IList <WorkQueuePriorityEnum> priorities = WorkQueuePriorityEnum.GetAll(); foreach (WorkQueuePriorityEnum priority in priorities) { PriorityDropDownList.Items.Add(new ListItem(ServerEnumDescription.GetLocalizedDescription(priority), priority.Lookup)); } ScheduleNowCheckBox.Checked = false; NewScheduleDate.Enabled = true; NewScheduleTime.Enabled = true; }
protected void ApplyChanges() { if (WorkQueues != null) { var toBeUpdatedList = new List <Model.WorkQueue>(); foreach (Model.WorkQueue item in WorkQueues) { if (item != null) { toBeUpdatedList.Add(item); } } if (toBeUpdatedList.Count > 0) { DateTime newScheduleTime = Platform.Time; if (WorkQueueSettingsPanel.NewScheduledDateTime != null && WorkQueueSettingsPanel.ScheduleNow == false) { newScheduleTime = WorkQueueSettingsPanel.NewScheduledDateTime.Value; } if (newScheduleTime < Platform.Time && WorkQueueSettingsPanel.ScheduleNow == false) { MessageDialog.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageDialog.Message = HttpContext.GetGlobalResourceObject("SR", "WorkQueueRescheduleFailed_MustBeInFuture") as string; MessageDialog.Show(); ModalDialog.Show(); } else { DateTime expirationTime = newScheduleTime.AddSeconds(WorkQueueSettings.Default.WorkQueueExpireDelaySeconds); WorkQueuePriorityEnum priority = WorkQueueSettingsPanel.SelectedPriority; try { var controller = new WorkQueueController(); bool result = controller.RescheduleWorkQueueItems(toBeUpdatedList, newScheduleTime, expirationTime, priority); if (result) { if (WorkQueueUpdated != null) { WorkQueueUpdated(toBeUpdatedList); } } else { Platform.Log(LogLevel.Error, "Unable to reschedule work queue items for user"); MessageDialog.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageDialog.Message = "Unable to reschedule this/these work queue items"; MessageDialog.Show(); } } catch (Exception e) { Platform.Log(LogLevel.Error, "Unable to reschedule work queue items for user : {0}", e.StackTrace); MessageDialog.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageDialog.Message = String.Format(HttpContext.GetGlobalResourceObject("SR", "WorkQueueRescheduleFailed_Exception") as string, e.Message); MessageDialog.Show(); } } } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); ClearScheduleDateButton.OnClientClick = ScriptHelper.ClearDate(ScheduleDate.ClientID, ScheduleCalendarExtender.ClientID); // setup child controls GridPagerTop.InitializeGridPager(SR.GridPagerWorkQueueSingleItem, SR.GridPagerWorkQueueMultipleItems, workQueueItemList.WorkQueueItemGridView, () => workQueueItemList.ResultCount, ImageServerConstants.GridViewPagerPosition.Top); workQueueItemList.Pager = GridPagerTop; workQueueItemList.ServerPartition = _serverPartition; workQueueItemList.DataSourceCreated += delegate(WorkQueueDataSource source) { if (!String.IsNullOrEmpty(PatientName.TrimText)) { source.PatientsName = SearchHelper.NameWildCard(PatientName.TrimText); } source.Partition = ServerPartition; if (!String.IsNullOrEmpty(PatientId.TrimText)) { source.PatientId = SearchHelper.TrailingWildCard(PatientId.TrimText); } if (!String.IsNullOrEmpty(ProcessingServer.TrimText)) { source.ProcessingServer = SearchHelper.TrailingWildCard(ProcessingServer.TrimText); } source.ScheduledDate = !string.IsNullOrEmpty(ScheduleDate.Text) ? ScheduleDate.Text : string.Empty; source.DateFormats = ScheduleCalendarExtender.Format; if (TypeListBox.SelectedIndex > -1) { var types = new List <WorkQueueTypeEnum>(); foreach (ListItem item in TypeListBox.Items) { if (item.Selected) { types.Add(WorkQueueTypeEnum.GetEnum(item.Value)); } } source.TypeEnums = types.ToArray(); } if (StatusListBox.SelectedIndex > -1) { var statuses = new List <WorkQueueStatusEnum>(); foreach (ListItem item in StatusListBox.Items) { if (item.Selected) { statuses.Add(WorkQueueStatusEnum.GetEnum(item.Value)); } } source.StatusEnums = statuses.ToArray(); } if (PriorityDropDownList.SelectedValue != string.Empty) { source.PriorityEnum = WorkQueuePriorityEnum.GetEnum(PriorityDropDownList.SelectedValue); } }; MessageBox.Confirmed += delegate { workQueueItemList.RefreshCurrentPage(); }; }
/// <summary> /// Reschedule a list of <see cref="WorkQueue"/> items /// </summary> /// <param name="items">List of <see cref="WorkQueue"/> items to be rescheduled</param> /// <param name="newScheduledTime">New schedule start date/time</param> /// <param name="expirationTime">New expiration date/time</param> /// <param name="priority">New priority</param> /// <returns>A value indicating whether all <see cref="WorkQueue"/> items in <paramref name="items"/> are updated successfully.</returns> /// <remarks> /// If one or more <see cref="WorkQueue"/> in <paramref name="items"/> cannot be rescheduled, all changes will be /// reverted and <b>false</b> will be returned. /// </remarks> public bool RescheduleWorkQueueItems(IList <WorkQueue> items, DateTime newScheduledTime, DateTime expirationTime, WorkQueuePriorityEnum priority) { if (items == null || items.Count == 0) { return(false); } WorkQueueUpdateColumns updatedColumns = new WorkQueueUpdateColumns(); updatedColumns.WorkQueuePriorityEnum = priority; updatedColumns.ScheduledTime = newScheduledTime; updatedColumns.ExpirationTime = expirationTime; updatedColumns.FailureCount = 0; updatedColumns.FailureDescription = String.Empty; updatedColumns.LastUpdatedTime = Platform.Time; bool result = false; IPersistentStore store = PersistentStoreRegistry.GetDefaultStore(); using (IUpdateContext ctx = store.OpenUpdateContext(UpdateContextSyncMode.Flush)) { IWorkQueueEntityBroker workQueueBroker = ctx.GetBroker <IWorkQueueEntityBroker>(); foreach (WorkQueue item in items) { result = workQueueBroker.Update(item.Key, updatedColumns); if (!result) { break; } } if (result) { ctx.Commit(); } } return(result); }
public void Update(Guid Guid, short EnumX, string Lookup, string Description, string LongDescription) { var item = new WorkQueuePriorityEnum(); item.MarkOld(); item.IsLoaded = true; item.Guid = Guid; item.EnumX = EnumX; item.Lookup = Lookup; item.Description = Description; item.LongDescription = LongDescription; item.Save(UserName); }
/// <summary> /// Insert an EditStudy request. /// </summary> /// <param name="context"></param> /// <param name="studyStorageKey"></param> /// <param name="serverPartitionKey"></param> /// <param name="type"></param> /// <param name="updateItems"></param> /// <param name="reason"></param> /// <param name="user"></param> /// <param name="editType"></param> /// <param name="priorityEnum">Optional parameter to set the priority of resultant <see cref="WorkQueue"/> items.</param> /// <returns></returns> private static WorkQueue InsertExternalEditStudyRequest(IUpdateContext context, ServerEntityKey studyStorageKey, ServerEntityKey serverPartitionKey, WorkQueueTypeEnum type, List <UpdateItem> updateItems, string reason, string user, EditType editType, WorkQueuePriorityEnum priorityEnum = null) { var propertiesBroker = context.GetBroker <IWorkQueueTypePropertiesEntityBroker>(); var criteria = new WorkQueueTypePropertiesSelectCriteria(); criteria.WorkQueueTypeEnum.EqualTo(type); WorkQueueTypeProperties properties = propertiesBroker.FindOne(criteria); var broker = context.GetBroker <IWorkQueueEntityBroker>(); var insert = new WorkQueueUpdateColumns(); DateTime now = Platform.Time; var data = new EditStudyWorkQueueData { EditRequest = { TimeStamp = now, UserId = user, UpdateEntries = updateItems, Reason = reason, EditType = editType } }; insert.WorkQueueTypeEnum = type; insert.StudyStorageKey = studyStorageKey; insert.ServerPartitionKey = serverPartitionKey; insert.ScheduledTime = now; insert.ExpirationTime = now.AddSeconds(properties.ExpireDelaySeconds); insert.WorkQueueStatusEnum = WorkQueueStatusEnum.Pending; insert.WorkQueuePriorityEnum = priorityEnum ?? properties.WorkQueuePriorityEnum; insert.Data = XmlUtils.SerializeAsXmlDoc(data); WorkQueue editEntry = broker.Insert(insert); if (editEntry == null) { throw new ApplicationException(string.Format("Unable to insert an Edit request of type {0} for study for user {1}", type.Description, user)); } return(editEntry); }
/// <summary> /// Insert an EditStudy request. /// </summary> /// <param name="context"></param> /// <param name="studyStorageKey"></param> /// <param name="serverPartitionKey"></param> /// <param name="type"></param> /// <param name="updateItems"></param> /// <param name="reason"></param> /// <param name="user"></param> /// <param name="editType"></param> /// <param name="priorityEnum">Optional parameter to set the priority of resultant <see cref="WorkQueue"/> items.</param> /// <returns></returns> private static WorkQueue InsertEditStudyRequest(IUpdateContext context, ServerEntityKey studyStorageKey, ServerEntityKey serverPartitionKey, WorkQueueTypeEnum type, List <UpdateItem> updateItems, string reason, string user, EditType editType, WorkQueuePriorityEnum priorityEnum = null) { var broker = context.GetBroker <IInsertWorkQueue>(); InsertWorkQueueParameters criteria = new EditStudyWorkQueueParameters(studyStorageKey, serverPartitionKey, type, updateItems, reason, user, editType); if (priorityEnum != null) { criteria.WorkQueuePriorityEnum = priorityEnum; } WorkQueue editEntry = broker.FindOne(criteria); if (editEntry == null) { throw new ApplicationException(string.Format("Unable to insert an Edit request of type {0} for study for user {1}", type.Description, user)); } return(editEntry); }
/// <summary> /// Inserts an External edit request(s) to update a study. /// </summary> /// <remarks> /// The External Edit request can be for a study in any state. The study could be offline/nearline/etc. /// </remarks> /// <param name="context">The persistence context used for database connection.</param> /// <param name="studyStorageKey">The StudyStorage record key</param> /// <param name="reason">The reason the study is being editted</param> /// <param name="user">A string identifying the user that triggered the edit and is stored with the history for the edit.</param> /// <exception cref="InvalidStudyStateOperationException"></exception> /// <param name="updateItems"></param> /// <param name="editType">The request is a web edit request </param> /// <param name="priorityEnum">Optional parameter to set the priority of resultant <see cref="WorkQueue"/> items.</param> public static IList <WorkQueue> ExternalEditStudy(IUpdateContext context, ServerEntityKey studyStorageKey, List <UpdateItem> updateItems, string reason, string user, EditType editType, WorkQueuePriorityEnum priorityEnum = null) { // Find all location of the study in the system and insert series delete request StudyStorage s = StudyStorage.Load(studyStorageKey); IList <WorkQueue> entries = new List <WorkQueue>(); // insert an edit request WorkQueue request = InsertExternalEditStudyRequest(context, s.Key, s.ServerPartitionKey, WorkQueueTypeEnum.ExternalEdit, updateItems, reason, user, editType, priorityEnum); entries.Add(request); return(entries); }
/// <summary> /// Inserts edit request(s) to update a study. /// </summary> /// <param name="context">The persistence context used for database connection.</param> /// <param name="studyStorageKey">The StudyStorage record key</param> /// <param name="reason">The reason the study is being editted</param> /// <param name="userId">The ID of the user requesting the study edit</param> /// <param name="editType">The request is a web edit request</param> /// <exception cref="InvalidStudyStateOperationException"></exception> /// <param name="priorityEnum">Optional parameter to set the priority of resultant <see cref="WorkQueue"/> items.</param> /// <param name="updateItems"></param> public static IList <WorkQueue> EditStudy(IUpdateContext context, ServerEntityKey studyStorageKey, List <UpdateItem> updateItems, string reason, string userId, EditType editType, WorkQueuePriorityEnum priorityEnum = null) { // Find all location of the study in the system and insert series delete request IList <StudyStorageLocation> storageLocations = StudyStorageLocation.FindStorageLocations(studyStorageKey); IList <WorkQueue> entries = new List <WorkQueue>(); foreach (StudyStorageLocation location in storageLocations) { if (location.StudyStatusEnum.Equals(StudyStatusEnum.OnlineLossy)) { if (location.IsLatestArchiveLossless) { throw new InvalidStudyStateOperationException("Study is lossy but was archived as lossless. It must be restored before editing."); } } try { string failureReason; if (ServerHelper.LockStudy(location.Key, QueueStudyStateEnum.EditScheduled, out failureReason)) { // insert an edit request WorkQueue request = InsertEditStudyRequest(context, location.Key, location.ServerPartitionKey, WorkQueueTypeEnum.WebEditStudy, updateItems, reason, userId, editType, priorityEnum); entries.Add(request); } else { throw new ApplicationException(String.Format("Unable to lock storage location {0} for edit : {1}", location.Key, failureReason)); } } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "Errors occured when trying to insert edit request"); if (!ServerHelper.UnlockStudy(location.Key)) { throw new ApplicationException("Unable to unlock the study"); } } } return(entries); }