/// <summary>
        /// Update a <see cref="RestoreQueue"/> entry.
        /// </summary>
        /// <param name="item">The item to update.</param>
        /// <param name="status">The status to set the entry to.</param>
        /// <param name="scheduledTime">The scheduled time to set the entry to.</param>
        /// <param name="updateContext">The update context</param>
        public bool UpdateRestoreQueue(IUpdateContext updateContext, RestoreQueue item, RestoreQueueStatusEnum status, DateTime scheduledTime)
        {
            UpdateRestoreQueueParameters parms = new UpdateRestoreQueueParameters();

            parms.RestoreQueueKey        = item.GetKey();
            parms.RestoreQueueStatusEnum = status;
            parms.ScheduledTime          = scheduledTime;
            parms.StudyStorageKey        = item.StudyStorageKey;
            if (!String.IsNullOrEmpty(item.FailureDescription))
            {
                parms.FailureDescription = item.FailureDescription;
            }

            IUpdateRestoreQueue broker = updateContext.GetBroker <IUpdateRestoreQueue>();

            if (broker.Execute(parms))
            {
                return(true);
            }

            Platform.Log(LogLevel.Error, "Unexpected failure updating RestoreQueue entry {0}", item.GetKey());
            return(false);
        }
 /// <summary>
 /// Creates an instance of <see cref="RestoreProcessorContext"/>
 /// </summary>
 /// <param name="item"></param>
 public RestoreProcessorContext(RestoreQueue item)
     : base(item.GetKey().Key.ToString())
 {
     Platform.CheckForNullReference(item, "item");
     _item = item;
 }
        protected override string GetTemporaryPath()
        {
            StudyStorageLocation storage = StudyStorageLocation.FindStorageLocations(StudyStorage.Load(_item.StudyStorageKey))[0];

            if (storage == null)
            {
                return(base.TempDirectory);
            }
            else
            {
                String basePath = GetTempPathRoot();

                if (String.IsNullOrEmpty(basePath))
                {
                    basePath = Path.Combine(storage.FilesystemPath, "temp");
                }
                String tempDirectory = Path.Combine(basePath, String.Format("RestoreQueue-{0}", _item.GetKey()));

                for (int i = 2; i < 1000; i++)
                {
                    if (!Directory.Exists(tempDirectory))
                    {
                        break;
                    }

                    tempDirectory = Path.Combine(basePath, String.Format("RestoreQueue-{0}({1})", _item.GetKey(), i));
                }

                if (!Directory.Exists(tempDirectory))
                {
                    Directory.CreateDirectory(tempDirectory);
                }

                return(tempDirectory);
            }
        }