示例#1
0
        private void TrackTask(PSTaskQueueItem task)
        {
            if (!this._db.IsSetup)
            {
                this._logger.Log(LogLevel.Error, "Can't track task -- DB not setup");
                return;
            }

            // Will fill in the db ID
            this._db.AddTaskQueueItem(task);

            if (this._isStarted)
            {
                this.StartTask(task);
            }
        }
示例#2
0
        private void StartTask(PSTaskQueueItem task)
        {
            Debug.Assert(task.TaskId != 0, "Should always have a task id");

            TaskInfo taskTracking = null;

            switch (task.TaskType)
            {
            case TaskType.Import:
                var importData = JsonConvert.DeserializeObject <TaskDataImport>(task.TaskDataSerialized);
                taskTracking = ImportFromPath(importData.RootPath);
                break;

            case TaskType.SendStudy:
                var sendData = JsonConvert.DeserializeObject <TaskDataSendStudy>(task.TaskDataSerialized);
                taskTracking = SendStudy(sendData.StudyInstanceUID, sendData.AETarget);
                break;

            case TaskType.DeleteStudy:
                var deleteData = JsonConvert.DeserializeObject <TaskDataDeleteStudy>(task.TaskDataSerialized);
                taskTracking = DeleteStudy(deleteData.StudyInstanceUID);
                break;

            default:
                // No idea what this is....
                this._logger.Log(LogLevel.Warning, "Unknown task type: " + task.TaskType + ", Ending Id " + task.TaskId);
                this._db.CompleteTaskQueueItem(task.TaskId);
                return;
            }

            Debug.Assert(taskTracking != null, "Should always have a tracking task");

            taskTracking.Task.ContinueWith(taskCompleted =>
            {
                this._db.CompleteTaskQueueItem(task.TaskId);
                this._tasksInProcess.Remove(task.TaskId);
            });

            this._tasksInProcess[task.TaskId] = taskTracking;
        }