public override void DataBind() { if (WorkQueueItemKey != null) { var adaptor = new WorkQueueAdaptor(); _workQueue = adaptor.Get(WorkQueueItemKey); WorkQueueItemDetailsPanel.WorkQueue = _workQueue; if (_workQueue == null) { if (!ItemNotAvailableAlertShown) { MessageBox.Message = SR.WorkQueueNotAvailable; MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; ItemNotAvailableAlertShown = true; } } } else { ExceptionHandler.ThrowException(new WorkQueueItemNotFoundException()); } base.DataBind(); }
/// <summary> /// Returns a value indicating whether the specified study has been scheduled for delete. /// </summary> /// <param name="study"></param> /// <param name="workQueueType"></param> /// <returns></returns> private static bool IsStudyInWorkQueue(Study study, WorkQueueTypeEnum workQueueType) { Platform.CheckForNullReference(study, "Study"); WorkQueueAdaptor adaptor = new WorkQueueAdaptor(); WorkQueueSelectCriteria workQueueCriteria = new WorkQueueSelectCriteria(); workQueueCriteria.WorkQueueTypeEnum.EqualTo(workQueueType); workQueueCriteria.ServerPartitionKey.EqualTo(study.ServerPartitionKey); workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey); workQueueCriteria.WorkQueueStatusEnum.EqualTo(WorkQueueStatusEnum.Pending); IList <WorkQueue> list = adaptor.Get(workQueueCriteria); if (list != null && list.Count > 0) { return(true); } workQueueCriteria.WorkQueueStatusEnum.EqualTo(WorkQueueStatusEnum.Idle); // not likely but who knows list = adaptor.Get(workQueueCriteria); if (list != null && list.Count > 0) { return(true); } return(false); }
public int GetRelatedWorkQueueCount(Device device) { WorkQueueAdaptor workQueueAdaptor = new WorkQueueAdaptor(); WorkQueueSelectCriteria criteria = new WorkQueueSelectCriteria(); criteria.DeviceKey.EqualTo(device.Key); return(workQueueAdaptor.GetCount(criteria)); }
public int GetCountPendingExternalEditWorkQueueItems(Study study) { Platform.CheckForNullReference(study, "Study"); var adaptor = new WorkQueueAdaptor(); var workQueueCriteria = new WorkQueueSelectCriteria(); workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey); workQueueCriteria.WorkQueueTypeEnum.EqualTo(WorkQueueTypeEnum.ExternalEdit); return(adaptor.GetCount(workQueueCriteria)); }
public int GetCountPendingWorkQueueItems(Study study) { Platform.CheckForNullReference(study, "Study"); var adaptor = new WorkQueueAdaptor(); var workQueueCriteria = new WorkQueueSelectCriteria(); workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey); workQueueCriteria.WorkQueueStatusEnum.In(new [] { WorkQueueStatusEnum.Idle, WorkQueueStatusEnum.InProgress, WorkQueueStatusEnum.Pending }); return(adaptor.GetCount(workQueueCriteria)); }
public IList <WorkQueue> GetWorkQueueItems(Study study) { Platform.CheckForNullReference(study, "Study"); WorkQueueAdaptor adaptor = new WorkQueueAdaptor(); WorkQueueSelectCriteria workQueueCriteria = new WorkQueueSelectCriteria(); workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey); workQueueCriteria.ScheduledTime.SortAsc(0); return(adaptor.Get(workQueueCriteria)); }
/// <summary> /// Popup a dialog to reschedule the work queue item. /// </summary> /// <param name="itemKey"></param> public void RescheduleWorkQueueItem(ServerEntityKey itemKey) { if (itemKey == null) { return; } var adaptor = new WorkQueueAdaptor(); Model.WorkQueue item = adaptor.Get(itemKey); if (item == null) { InformationDialog.Message = SR.WorkQueueNotAvailable; InformationDialog.Show(); } else { if (item.WorkQueueStatusEnum == WorkQueueStatusEnum.InProgress) { // prompt the user first InformationDialog.Message = SR.WorkQueueBeingProcessed_CannotReschedule; InformationDialog.MessageType = MessageBox.MessageTypeEnum.ERROR; InformationDialog.Show(); return; } if (item.WorkQueueStatusEnum == WorkQueueStatusEnum.Failed) { InformationDialog.Message = SR.WorkQueueFailed_CannotReschedule; InformationDialog.MessageType = MessageBox.MessageTypeEnum.ERROR; InformationDialog.Show(); return; } ScheduleWorkQueueDialog.WorkQueueKeys = new List <ServerEntityKey> { itemKey }; ScheduleWorkQueueDialog.Reset(); ScheduleWorkQueueDialog.Show(); } }
public bool MoveStudy(Study study, Device device, IList <Series> seriesList) { if (seriesList != null) { using ( IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { ServerPartition partition = ServerPartition.Load(study.ServerPartitionKey); List <string> seriesUids = new List <string>(); foreach (Series series in seriesList) { seriesUids.Add(series.SeriesInstanceUid); } IList <WorkQueue> entries = StudyEditorHelper.MoveSeries(context, partition, study.StudyInstanceUid, device.Key, seriesUids); if (entries != null) { context.Commit(); } return(true); } } WorkQueueAdaptor workqueueAdaptor = new WorkQueueAdaptor(); DateTime time = Platform.Time; WorkQueueUpdateColumns columns = new WorkQueueUpdateColumns { WorkQueueTypeEnum = WorkQueueTypeEnum.WebMoveStudy, WorkQueueStatusEnum = WorkQueueStatusEnum.Pending, ServerPartitionKey = study.ServerPartitionKey, StudyStorageKey = study.StudyStorageKey, FailureCount = 0, DeviceKey = device.Key, ScheduledTime = time, ExpirationTime = time.AddMinutes(4) }; workqueueAdaptor.Add(columns); return(true); }
public IList <WorkQueueInfo> GetWorkQueueOverview() { IList <WorkQueueInfo> workQueueInfo = new List <WorkQueueInfo>(); WorkQueueProcessorIDsParameters parameters = new WorkQueueProcessorIDsParameters(); IWorkQueueProcessorIDs broker = HttpContextData.Current.ReadContext.GetBroker <IWorkQueueProcessorIDs>(); IList <WorkQueue> processorIDList = broker.Find(parameters); WorkQueueSelectCriteria criteria = new WorkQueueSelectCriteria(); WorkQueueAdaptor adaptor = new WorkQueueAdaptor(); int numItems = 0; foreach (WorkQueue row in processorIDList) { criteria.ProcessorID.EqualTo(row.ProcessorID); numItems = adaptor.GetCount(criteria); workQueueInfo.Add(new WorkQueueInfo(row.ProcessorID, numItems)); } return(workQueueInfo); }
/// <summary> /// Popup a dialog to reschedule the work queue item. /// </summary> /// <param name="itemKey"></param> public void RescheduleWorkQueueItem(ServerEntityKey itemKey) { if (itemKey == null) return; var adaptor = new WorkQueueAdaptor(); Model.WorkQueue item = adaptor.Get(itemKey); if (item==null) { InformationDialog.Message = SR.WorkQueueNotAvailable; InformationDialog.Show(); } else { if (item.WorkQueueStatusEnum == WorkQueueStatusEnum.InProgress) { // prompt the user first InformationDialog.Message = SR.WorkQueueBeingProcessed_CannotReschedule; InformationDialog.MessageType = MessageBox.MessageTypeEnum.ERROR; InformationDialog.Show(); return; } if (item.WorkQueueStatusEnum == WorkQueueStatusEnum.Failed) { InformationDialog.Message = SR.WorkQueueFailed_CannotReschedule; InformationDialog.MessageType = MessageBox.MessageTypeEnum.ERROR; InformationDialog.Show(); return; } ScheduleWorkQueueDialog.WorkQueueKeys = new List<ServerEntityKey> {itemKey}; ScheduleWorkQueueDialog.Reset(); ScheduleWorkQueueDialog.Show(); } }
private void PreResetConfirmDialog_Confirmed(object data) { Hide(); var key = data as ServerEntityKey; if (key != null) { var adaptor = new WorkQueueAdaptor(); Model.WorkQueue item = adaptor.Get(key); if (item == null) { String errorMessage = SR.WorkQueueNotAvailable; EventsHelper.Fire(Error, this, new WorkQueueItemResetErrorEventArgs(errorMessage, null)); } else { var controller = new WorkQueueController(); DateTime scheduledTime = item.ScheduledTime; if (scheduledTime < Platform.Time) scheduledTime = Platform.Time.AddSeconds(WorkQueueSettings.Default.WorkQueueProcessDelaySeconds); DateTime expirationTime = item.ExpirationTime; if (expirationTime < scheduledTime) expirationTime = scheduledTime.AddSeconds(WorkQueueSettings.Default.WorkQueueExpireDelaySeconds); try { var items = new List<Model.WorkQueue>(); items.Add(item); controller.ResetWorkQueueItems(items, scheduledTime, expirationTime); Platform.Log(LogLevel.Info, "{0} Work Queue item reset: Key={1}.", item.WorkQueueTypeEnum, item.GetKey()); if (WorkQueueItemReseted != null) WorkQueueItemReseted(item); if (OnHide != null) OnHide(); } catch (Exception e) { Platform.Log(LogLevel.Error, e, "Unable to reset {0} work queue item. Key={1}.", item.WorkQueueTypeEnum, item.GetKey()); String errorMessage = String.Format(SR.WorkQueueResetFailed, e.Message); EventsHelper.Fire(Error, this, new WorkQueueItemResetErrorEventArgs(errorMessage, e)); } } } }
public int GetCountPendingExternalEditWorkQueueItems(Study study) { Platform.CheckForNullReference(study, "Study"); var adaptor = new WorkQueueAdaptor(); var workQueueCriteria = new WorkQueueSelectCriteria(); workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey); workQueueCriteria.WorkQueueTypeEnum.EqualTo(WorkQueueTypeEnum.ExternalEdit); return adaptor.GetCount(workQueueCriteria); }
public IList<WorkQueue> GetWorkQueueItems(Study study) { Platform.CheckForNullReference(study, "Study"); WorkQueueAdaptor adaptor = new WorkQueueAdaptor(); WorkQueueSelectCriteria workQueueCriteria = new WorkQueueSelectCriteria(); workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey); workQueueCriteria.ScheduledTime.SortAsc(0); return adaptor.Get(workQueueCriteria); }
public bool MoveStudy(Study study, Device device, IList<Series> seriesList) { if (seriesList != null) { using ( IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { ServerPartition partition = ServerPartition.Load(study.ServerPartitionKey); List<string> seriesUids = new List<string>(); foreach (Series series in seriesList) { seriesUids.Add(series.SeriesInstanceUid); } IList<WorkQueue> entries = StudyEditorHelper.MoveSeries(context, partition, study.StudyInstanceUid, device.Key, seriesUids); if(entries != null) context.Commit(); return true; } } WorkQueueAdaptor workqueueAdaptor = new WorkQueueAdaptor(); DateTime time = Platform.Time; WorkQueueUpdateColumns columns = new WorkQueueUpdateColumns { WorkQueueTypeEnum = WorkQueueTypeEnum.WebMoveStudy, WorkQueueStatusEnum = WorkQueueStatusEnum.Pending, ServerPartitionKey = study.ServerPartitionKey, StudyStorageKey = study.StudyStorageKey, FailureCount = 0, DeviceKey = device.Key, ScheduledTime = time, ExpirationTime = time.AddMinutes(4) }; workqueueAdaptor.Add(columns); return true; }
public override void DataBind() { if (WorkQueueItemKey != null) { var adaptor = new WorkQueueAdaptor(); _workQueue = adaptor.Get(WorkQueueItemKey); WorkQueueItemDetailsPanel.WorkQueue = _workQueue; if (_workQueue == null) { if (!ItemNotAvailableAlertShown) { MessageBox.Message = SR.WorkQueueNotAvailable; MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; ItemNotAvailableAlertShown = true; } } } else { ExceptionHandler.ThrowException(new WorkQueueItemNotFoundException()); } base.DataBind(); }
private void PreResetConfirmDialog_Confirmed(object data) { Hide(); var key = data as ServerEntityKey; if (key != null) { var adaptor = new WorkQueueAdaptor(); Model.WorkQueue item = adaptor.Get(key); if (item == null) { String errorMessage = SR.WorkQueueNotAvailable; EventsHelper.Fire(Error, this, new WorkQueueItemResetErrorEventArgs(errorMessage, null)); } else { var controller = new WorkQueueController(); DateTime scheduledTime = item.ScheduledTime; if (scheduledTime < Platform.Time) { scheduledTime = Platform.Time.AddSeconds(WorkQueueSettings.Default.WorkQueueProcessDelaySeconds); } DateTime expirationTime = item.ExpirationTime; if (expirationTime < scheduledTime) { expirationTime = scheduledTime.AddSeconds(WorkQueueSettings.Default.WorkQueueExpireDelaySeconds); } try { var items = new List <Model.WorkQueue>(); items.Add(item); controller.ResetWorkQueueItems(items, scheduledTime, expirationTime); Platform.Log(LogLevel.Info, "{0} Work Queue item reset: Key={1}.", item.WorkQueueTypeEnum, item.GetKey()); if (WorkQueueItemReseted != null) { WorkQueueItemReseted(item); } if (OnHide != null) { OnHide(); } } catch (Exception e) { Platform.Log(LogLevel.Error, e, "Unable to reset {0} work queue item. Key={1}.", item.WorkQueueTypeEnum, item.GetKey()); String errorMessage = String.Format(SR.WorkQueueResetFailed, e.Message); EventsHelper.Fire(Error, this, new WorkQueueItemResetErrorEventArgs(errorMessage, e)); } } } }
public IList<WorkQueueInfo> GetWorkQueueOverview() { IList<WorkQueueInfo> workQueueInfo = new List<WorkQueueInfo>(); WorkQueueProcessorIDsParameters parameters = new WorkQueueProcessorIDsParameters(); IWorkQueueProcessorIDs broker = HttpContext.Current.GetSharedPersistentContext().GetBroker<IWorkQueueProcessorIDs>(); IList<WorkQueue> processorIDList = broker.Find(parameters); WorkQueueSelectCriteria criteria = new WorkQueueSelectCriteria(); WorkQueueAdaptor adaptor = new WorkQueueAdaptor(); int numItems = 0; foreach(WorkQueue row in processorIDList) { criteria.ProcessorID.EqualTo(row.ProcessorID); numItems = adaptor.GetCount(criteria); workQueueInfo.Add(new WorkQueueInfo(row.ProcessorID, numItems)); } return workQueueInfo; }
private static void ReconcileStudy(string command,StudyIntegrityQueue item ) { //Ignore the reconcile command if the item is null. if (item == null) return; // Preload the change description so its not done during the DB transaction XmlDocument changeDescription = new XmlDocument(); changeDescription.LoadXml(command); // The Xml in the SIQ item was generated when the images were received and put into the SIQ. // We now add the user info to it so that it will be logged in the history ReconcileStudyWorkQueueData queueData = XmlUtils.Deserialize<ReconcileStudyWorkQueueData>(item.Details); queueData.TimeStamp = Platform.Time; queueData.UserId = ServerHelper.CurrentUserName; using (IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { LockStudyParameters lockParms = new LockStudyParameters { QueueStudyStateEnum = QueueStudyStateEnum.ReconcileScheduled, StudyStorageKey = item.StudyStorageKey }; ILockStudy broker = context.GetBroker<ILockStudy>(); broker.Execute(lockParms); if (!lockParms.Successful) { throw new ApplicationException(lockParms.FailureReason); } //Add to Study History StudyHistoryeAdaptor historyAdaptor = new StudyHistoryeAdaptor(); StudyHistoryUpdateColumns parameters = new StudyHistoryUpdateColumns { StudyData = item.StudyData, ChangeDescription = changeDescription, StudyStorageKey = item.StudyStorageKey, StudyHistoryTypeEnum = StudyHistoryTypeEnum.StudyReconciled }; StudyHistory history = historyAdaptor.Add(context, parameters); //Create WorkQueue Entry WorkQueueAdaptor workQueueAdaptor = new WorkQueueAdaptor(); WorkQueueUpdateColumns row = new WorkQueueUpdateColumns { Data = XmlUtils.SerializeAsXmlDoc(queueData), ServerPartitionKey = item.ServerPartitionKey, StudyStorageKey = item.StudyStorageKey, StudyHistoryKey = history.GetKey(), WorkQueueTypeEnum = WorkQueueTypeEnum.ReconcileStudy, WorkQueueStatusEnum = WorkQueueStatusEnum.Pending, ScheduledTime = Platform.Time, ExpirationTime = Platform.Time.AddHours(1), GroupID = item.GroupID }; WorkQueue newWorkQueueItem = workQueueAdaptor.Add(context, row); StudyIntegrityQueueUidAdaptor studyIntegrityQueueUidAdaptor = new StudyIntegrityQueueUidAdaptor(); StudyIntegrityQueueUidSelectCriteria crit = new StudyIntegrityQueueUidSelectCriteria(); crit.StudyIntegrityQueueKey.EqualTo(item.GetKey()); IList<StudyIntegrityQueueUid> uidList = studyIntegrityQueueUidAdaptor.Get(context, crit); WorkQueueUidAdaptor workQueueUidAdaptor = new WorkQueueUidAdaptor(); WorkQueueUidUpdateColumns update = new WorkQueueUidUpdateColumns(); foreach (StudyIntegrityQueueUid uid in uidList) { update.WorkQueueKey = newWorkQueueItem.GetKey(); update.SeriesInstanceUid = uid.SeriesInstanceUid; update.SopInstanceUid = uid.SopInstanceUid; update.RelativePath = uid.RelativePath; workQueueUidAdaptor.Add(context, update); } //DeleteStudyIntegrityQueue Item StudyIntegrityQueueUidSelectCriteria criteria = new StudyIntegrityQueueUidSelectCriteria(); criteria.StudyIntegrityQueueKey.EqualTo(item.GetKey()); studyIntegrityQueueUidAdaptor.Delete(context, criteria); StudyIntegrityQueueAdaptor studyIntegrityQueueAdaptor = new StudyIntegrityQueueAdaptor(); studyIntegrityQueueAdaptor.Delete(context, item.GetKey()); context.Commit(); } }
/// <summary> /// Returns a value indicating whether the specified study has been scheduled for delete. /// </summary> /// <param name="study"></param> /// <param name="workQueueType"></param> /// <returns></returns> private static bool IsStudyInWorkQueue(Study study, WorkQueueTypeEnum workQueueType) { Platform.CheckForNullReference(study, "Study"); WorkQueueAdaptor adaptor = new WorkQueueAdaptor(); WorkQueueSelectCriteria workQueueCriteria = new WorkQueueSelectCriteria(); workQueueCriteria.WorkQueueTypeEnum.EqualTo(workQueueType); workQueueCriteria.ServerPartitionKey.EqualTo(study.ServerPartitionKey); workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey); workQueueCriteria.WorkQueueStatusEnum.EqualTo(WorkQueueStatusEnum.Pending); IList<WorkQueue> list = adaptor.Get(workQueueCriteria); if (list != null && list.Count > 0) return true; workQueueCriteria.WorkQueueStatusEnum.EqualTo(WorkQueueStatusEnum.Idle); // not likely but who knows list = adaptor.Get(workQueueCriteria); if (list != null && list.Count > 0) return true; return false; }
private static void ReconcileStudy(string command, StudyIntegrityQueue item) { //Ignore the reconcile command if the item is null. if (item == null) { return; } // Preload the change description so its not done during the DB transaction XmlDocument changeDescription = new XmlDocument(); changeDescription.LoadXml(command); // The Xml in the SIQ item was generated when the images were received and put into the SIQ. // We now add the user info to it so that it will be logged in the history ReconcileStudyWorkQueueData queueData = XmlUtils.Deserialize <ReconcileStudyWorkQueueData>(item.Details); queueData.TimeStamp = Platform.Time; queueData.UserId = ServerHelper.CurrentUserName; using (IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { LockStudyParameters lockParms = new LockStudyParameters { QueueStudyStateEnum = QueueStudyStateEnum.ReconcileScheduled, StudyStorageKey = item.StudyStorageKey }; ILockStudy broker = context.GetBroker <ILockStudy>(); broker.Execute(lockParms); if (!lockParms.Successful) { throw new ApplicationException(lockParms.FailureReason); } //Add to Study History StudyHistoryeAdaptor historyAdaptor = new StudyHistoryeAdaptor(); StudyHistoryUpdateColumns parameters = new StudyHistoryUpdateColumns { StudyData = item.StudyData, ChangeDescription = changeDescription, StudyStorageKey = item.StudyStorageKey, StudyHistoryTypeEnum = StudyHistoryTypeEnum.StudyReconciled }; StudyHistory history = historyAdaptor.Add(context, parameters); //Create WorkQueue Entry WorkQueueAdaptor workQueueAdaptor = new WorkQueueAdaptor(); WorkQueueUpdateColumns row = new WorkQueueUpdateColumns { Data = XmlUtils.SerializeAsXmlDoc(queueData), ServerPartitionKey = item.ServerPartitionKey, StudyStorageKey = item.StudyStorageKey, StudyHistoryKey = history.GetKey(), WorkQueueTypeEnum = WorkQueueTypeEnum.ReconcileStudy, WorkQueueStatusEnum = WorkQueueStatusEnum.Pending, ScheduledTime = Platform.Time, ExpirationTime = Platform.Time.AddHours(1), GroupID = item.GroupID }; WorkQueue newWorkQueueItem = workQueueAdaptor.Add(context, row); StudyIntegrityQueueUidAdaptor studyIntegrityQueueUidAdaptor = new StudyIntegrityQueueUidAdaptor(); StudyIntegrityQueueUidSelectCriteria crit = new StudyIntegrityQueueUidSelectCriteria(); crit.StudyIntegrityQueueKey.EqualTo(item.GetKey()); IList <StudyIntegrityQueueUid> uidList = studyIntegrityQueueUidAdaptor.Get(context, crit); WorkQueueUidAdaptor workQueueUidAdaptor = new WorkQueueUidAdaptor(); WorkQueueUidUpdateColumns update = new WorkQueueUidUpdateColumns(); foreach (StudyIntegrityQueueUid uid in uidList) { update.WorkQueueKey = newWorkQueueItem.GetKey(); update.SeriesInstanceUid = uid.SeriesInstanceUid; update.SopInstanceUid = uid.SopInstanceUid; update.RelativePath = uid.RelativePath; workQueueUidAdaptor.Add(context, update); } //DeleteStudyIntegrityQueue Item StudyIntegrityQueueUidSelectCriteria criteria = new StudyIntegrityQueueUidSelectCriteria(); criteria.StudyIntegrityQueueKey.EqualTo(item.GetKey()); studyIntegrityQueueUidAdaptor.Delete(context, criteria); StudyIntegrityQueueAdaptor studyIntegrityQueueAdaptor = new StudyIntegrityQueueAdaptor(); studyIntegrityQueueAdaptor.Delete(context, item.GetKey()); context.Commit(); } }
public int GetCountPendingWorkQueueItems(Study study) { Platform.CheckForNullReference(study, "Study"); var adaptor = new WorkQueueAdaptor(); var workQueueCriteria = new WorkQueueSelectCriteria(); workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey); workQueueCriteria.WorkQueueStatusEnum.In(new [] {WorkQueueStatusEnum.Idle, WorkQueueStatusEnum.InProgress, WorkQueueStatusEnum.Pending}); return adaptor.GetCount(workQueueCriteria); }
public int GetRelatedWorkQueueCount(Device device) { WorkQueueAdaptor workQueueAdaptor = new WorkQueueAdaptor(); WorkQueueSelectCriteria criteria = new WorkQueueSelectCriteria(); criteria.DeviceKey.EqualTo(device.Key); return workQueueAdaptor.GetCount(criteria); }
private void PreDeleteConfirmDialog_Confirmed(object data) { Hide(); var key = data as ServerEntityKey; if (key != null) { var adaptor = new WorkQueueAdaptor(); Model.WorkQueue item = adaptor.Get(key); if (item == null) { MessageBox.Message = SR.WorkQueueNotAvailable; MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageBox.Show(); } else { if (item.WorkQueueStatusEnum == WorkQueueStatusEnum.InProgress) { MessageBox.Message = SR.WorkQueueBeingProcessed_CannotDelete; MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageBox.Show(); return; } try { bool successful; var controller = new WorkQueueController(); var items = new List <Model.WorkQueue>(); items.Add(item); successful = controller.DeleteWorkQueueItems(items); if (successful) { Platform.Log(LogLevel.Info, "Work Queue item deleted by user : Item Key={0}", item.GetKey().Key); if (WorkQueueItemDeleted != null) { WorkQueueItemDeleted(item); } if (OnHide != null) { OnHide(); } } else { Platform.Log(LogLevel.Error, "PreResetConfirmDialog_Confirmed: Unable to delete work queue item. GUID={0}", item.GetKey().Key); MessageBox.Message = SR.WorkQueueDeleteFailed; MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageBox.Show(); } } catch (Exception e) { Platform.Log(LogLevel.Error, "PreResetConfirmDialog_Confirmed: Unable to delete work queue item. GUID={0} : {1}", item.GetKey().Key, e.StackTrace); MessageBox.Message = String.Format(SR.WorkQueueDeleteFailed_WithException, e.Message); MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageBox.Show(); } } } }
private void PreDeleteConfirmDialog_Confirmed(object data) { Hide(); var key = data as ServerEntityKey; if (key != null) { var adaptor = new WorkQueueAdaptor(); Model.WorkQueue item = adaptor.Get(key); if (item == null) { MessageBox.Message = SR.WorkQueueNotAvailable; MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageBox.Show(); } else { if (item.WorkQueueStatusEnum == WorkQueueStatusEnum.InProgress) { MessageBox.Message = SR.WorkQueueBeingProcessed_CannotDelete; MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageBox.Show(); return; } try { bool successful; var controller = new WorkQueueController(); var items = new List<Model.WorkQueue>(); items.Add(item); successful = controller.DeleteWorkQueueItems(items); if (successful) { Platform.Log(LogLevel.Info, "Work Queue item deleted by user : Item Key={0}", item.GetKey().Key); if (WorkQueueItemDeleted != null) WorkQueueItemDeleted(item); if (OnHide != null) OnHide(); } else { Platform.Log(LogLevel.Error, "PreResetConfirmDialog_Confirmed: Unable to delete work queue item. GUID={0}", item.GetKey().Key); MessageBox.Message = SR.WorkQueueDeleteFailed; MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageBox.Show(); } } catch (Exception e) { Platform.Log(LogLevel.Error, "PreResetConfirmDialog_Confirmed: Unable to delete work queue item. GUID={0} : {1}", item.GetKey().Key, e.StackTrace); MessageBox.Message = String.Format(SR.WorkQueueDeleteFailed_WithException, e.Message); MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageBox.Show(); } } } }