示例#1
0
        /// <summary>
        /// Constructs an instance of <see cref="WorkQueueSummary"/> based on a <see cref="WorkQueue"/> object.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        /// <remark>
        ///
        /// </remark>
        private WorkQueueSummary CreateWorkQueueSummary(WorkQueue item)
        {
            WorkQueueSummary summary = new WorkQueueSummary
            {
                TheWorkQueueItem = item,
                ThePartition     = Partition
            };

            // Fetch the patient info:
            StudyStorageAdaptor ssAdaptor = new StudyStorageAdaptor();
            StudyStorage        storages  = ssAdaptor.Get(item.StudyStorageKey);

            if (storages == null)
            {
                summary.PatientId    = "N/A";
                summary.PatientsName = "N/A";
                return(summary);
            }
            StudyAdaptor        studyAdaptor  = new StudyAdaptor();
            StudySelectCriteria studycriteria = new StudySelectCriteria();

            studycriteria.StudyInstanceUid.EqualTo(storages.StudyInstanceUid);
            studycriteria.ServerPartitionKey.EqualTo(item.ServerPartitionKey);
            IList <Study> studyList = studyAdaptor.Get(studycriteria);

            if (studyList == null || studyList.Count == 0)
            {
                summary.PatientId    = "N/A";
                summary.PatientsName = "N/A";
            }
            else
            {
                summary.PatientId    = studyList[0].PatientId;
                summary.PatientsName = studyList[0].PatientsName;
            }

            if (item.WorkQueueTypeEnum == WorkQueueTypeEnum.WebMoveStudy ||
                item.WorkQueueTypeEnum == WorkQueueTypeEnum.AutoRoute)
            {
                DeviceDataAdapter deviceAdaptor = new DeviceDataAdapter();
                Device            dest          = deviceAdaptor.Get(item.DeviceKey);

                summary.Notes = String.Format("Destination AE : {0}", dest.AeTitle);

                if (item.FailureDescription != null)
                {
                    summary.FullDescription = String.Format("{0}, {1}", summary.Notes, item.FailureDescription);                       //Set the FullDescription for the Tooltip in the GUI
                    summary.Notes           = summary.FullDescription.Length > 60
                                                ? summary.FullDescription.Substring(0, 60)
                                                : summary.FullDescription;
                }
            }
            else if (item.FailureDescription != null)
            {
                // This used to only be shown when the status was "Failed" for a
                // queue entry.  We now show it any time there's
                if (item.FailureDescription.Length > 60)
                {
                    summary.Notes           = item.FailureDescription.Substring(0, 60);
                    summary.Notes          += " ...";
                    summary.FullDescription = item.FailureDescription;                  //Set the FullDescription for the Tooltip in the GUI
                }
                else
                {
                    summary.Notes = item.FailureDescription;
                }
            }

            summary.RequiresAttention = item.WorkQueueStatusEnum.Equals(WorkQueueStatusEnum.Failed) || !ServerPlatform.IsActiveWorkQueue(item);
            return(summary);
        }
        /// <summary>
        /// Returns a value indicating whether the specified <see cref="WorkQueue"/> can be manually deleted from the queue.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        static public bool CanDelete(WorkQueue item)
        {
            if (item == null)
            {
                return(false);
            }

            return
                /* failed item */
                (item.WorkQueueStatusEnum == WorkQueueStatusEnum.Failed
                 /* completed item */
                 || (item.WorkQueueStatusEnum == WorkQueueStatusEnum.Completed)
                 /* nobody claimed it */
                 ||
                 (item.WorkQueueStatusEnum == WorkQueueStatusEnum.InProgress &&
                  String.IsNullOrEmpty(item.ProcessorID))
                 // allow deletes of some pending entries
                 ||
                 (item.WorkQueueStatusEnum != WorkQueueStatusEnum.InProgress &&
                  item.WorkQueueTypeEnum == WorkQueueTypeEnum.WebMoveStudy)
                 ||
                 (item.WorkQueueStatusEnum != WorkQueueStatusEnum.InProgress &&
                  item.WorkQueueTypeEnum == WorkQueueTypeEnum.WebEditStudy)
                 ||
                 (item.WorkQueueStatusEnum != WorkQueueStatusEnum.InProgress &&
                  item.WorkQueueTypeEnum == WorkQueueTypeEnum.AutoRoute)
                 ||
                 (item.WorkQueueStatusEnum != WorkQueueStatusEnum.InProgress &&
                  item.WorkQueueTypeEnum == WorkQueueTypeEnum.WebDeleteStudy)

                 /* allow deletes of "stuck" items (except items that are InProgress)*/
                 || (!item.WorkQueueStatusEnum.Equals(WorkQueueStatusEnum.InProgress) && !ServerPlatform.IsActiveWorkQueue(item)));
        }
        public override void DataBind()
        {
            if (_detailsView == null && WorkQueue != null)
            {
                ItemStudy = WorkQueue.Study;

                if (WorkQueue.WorkQueueTypeEnum == WorkQueueTypeEnum.AutoRoute)
                {
                    _detailsView = LoadControl("AutoRouteWorkQueueDetailsView.ascx") as WorkQueueDetailsViewBase;
                    if (_detailsView != null)
                    {
                        WorkQueueDetailsViewPlaceHolder.Controls.Add(_detailsView);
                    }
                }
                else if (WorkQueue.WorkQueueTypeEnum == WorkQueueTypeEnum.WebMoveStudy)
                {
                    _detailsView = LoadControl("WebMoveStudyWorkQueueDetailsView.ascx") as WorkQueueDetailsViewBase;
                    if (_detailsView != null)
                    {
                        WorkQueueDetailsViewPlaceHolder.Controls.Add(_detailsView);
                    }
                }
                else if (WorkQueue.WorkQueueTypeEnum == WorkQueueTypeEnum.WebEditStudy)
                {
                    _detailsView = LoadControl("WebEditStudyWorkQueueDetailsView.ascx") as WorkQueueDetailsViewBase;
                    if (_detailsView != null)
                    {
                        WorkQueueDetailsViewPlaceHolder.Controls.Add(_detailsView);
                    }
                }
                else if (WorkQueue.WorkQueueTypeEnum == WorkQueueTypeEnum.MigrateStudy)
                {
                    _detailsView = LoadControl("TierMigrationWorkQueueDetailsView.ascx") as WorkQueueDetailsViewBase;
                    if (_detailsView != null)
                    {
                        WorkQueueDetailsViewPlaceHolder.Controls.Add(_detailsView);
                    }
                }
                else if (WorkQueue.WorkQueueTypeEnum == WorkQueueTypeEnum.ProcessDuplicate)
                {
                    _detailsView = LoadControl("ProcessDuplicateWorkQueueDetailsView.ascx") as WorkQueueDetailsViewBase;
                    if (_detailsView != null)
                    {
                        WorkQueueDetailsViewPlaceHolder.Controls.Add(_detailsView);
                    }
                }
                else if (WorkQueue.WorkQueueTypeEnum == WorkQueueTypeEnum.ExternalEdit || WorkQueue.WorkQueueTypeEnum == WorkQueueTypeEnum.WebEditStudy)
                {
                    _detailsView = LoadControl("EditWorkQueueDetailsView.ascx") as WorkQueueDetailsViewBase;
                    if (_detailsView != null)
                    {
                        WorkQueueDetailsViewPlaceHolder.Controls.Add(_detailsView);
                    }
                }
                else
                {
                    _detailsView = LoadControl("GeneralWorkQueueDetailsView.ascx") as WorkQueueDetailsViewBase;
                    if (_detailsView != null)
                    {
                        WorkQueueDetailsViewPlaceHolder.Controls.Add(_detailsView);
                    }
                }

                // If the entry isn't failed but hasn't been updated for some time, display the alert message
                WorkQueueAlertPanelRow.Visible = false;
                if (!WorkQueue.WorkQueueStatusEnum.Equals(WorkQueueStatusEnum.Failed) &&
                    !ServerPlatform.IsActiveWorkQueue(WorkQueue))
                {
                    WorkQueueAlertPanelRow.Visible = true;
                    WorkQueueAlertPanel.Text       =
                        WorkQueue.LastUpdatedTime > DateTime.MinValue
                            ? String.Format(
                            "There does not seem to be any activity for this entry since {0}. The server may not be running or there is a problem with this entry.",
                            WorkQueue.LastUpdatedTime)
                            : "There does not seem to be any activity for this entry. The server may not be running or there is a problem with this entry.";
                }
            }
            if (_detailsView != null)
            {
                _detailsView.WorkQueue = WorkQueue;
            }

            base.DataBind();
        }
        /// <summary>
        /// Returns a value indicating whether the specified <see cref="WorkQueue"/> can be manually reset.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        static public bool CanReset(WorkQueue item)
        {
            if (item == null)
            {
                return(false);
            }

            return
                /* failed item */
                (item.WorkQueueStatusEnum == WorkQueueStatusEnum.Failed
                 /* nobody claimed it */
                 || (item.WorkQueueStatusEnum == WorkQueueStatusEnum.InProgress && String.IsNullOrEmpty(item.ProcessorID))
                 /* allow reset "stuck" items (except items that are InProgress)*/
                 || (!item.WorkQueueStatusEnum.Equals(WorkQueueStatusEnum.InProgress) && !ServerPlatform.IsActiveWorkQueue(item)));
        }