/// <summary>
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        /// <remarks>
        /// The reconciliation commands should be specified in <ImageCommands> node.
        /// </remarks>
        public IReconcileProcessor Parse(XmlDocument doc)
        {
            //TODO: Validate the xml
            Platform.CheckForNullReference(doc, "doc");

            if (doc.DocumentElement != null)
            {
                StudyReconcileDescriptorParser parser = new StudyReconcileDescriptorParser();
                StudyReconcileDescriptor       desc   = parser.Parse(doc);
                switch (desc.Action)
                {
                case StudyReconcileAction.CreateNewStudy: return(new ReconcileCreateStudyProcessor());

                case StudyReconcileAction.Discard: return(new DiscardImageCommandProcessor());

                case StudyReconcileAction.Merge: return(new MergeStudyCommandProcessor());

                case StudyReconcileAction.ProcessAsIs: return(new ReconcileProcessAsIsProcessor());

                default:
                    throw new NotSupportedException(String.Format("Reconcile Action: {0}", desc.Action));
                }
            }

            return(null);
        }
示例#2
0
        protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
        {
            IStudyHistoryEntityBroker historyUpdateBroker = updateContext.GetBroker <IStudyHistoryEntityBroker>();
            StudyHistoryUpdateColumns parms = new StudyHistoryUpdateColumns {
                DestStudyStorageKey = _destStudy.Key
            };

            if (_map != null)
            {
                // replace the mapping in the history
                StudyReconcileDescriptor changeLog = XmlUtils.Deserialize <StudyReconcileDescriptor>(_studyHistory.ChangeDescription);
                changeLog.SeriesMappings = new System.Collections.Generic.List <SeriesMapping>(_map.GetSeriesMappings());
                parms.ChangeDescription  = XmlUtils.SerializeAsXmlDoc(changeLog);
            }

            historyUpdateBroker.Update(_studyHistory.Key, parms);
        }
        private AutoReconcilerResult ApplyHistories(DicomFile file, IList <StudyHistory> histories)
        {
            Platform.CheckForNullReference(file, "file");
            Platform.CheckForNullReference(histories, "histories");

            AutoReconcilerResult preProcessingResult = null;

            StudyHistory lastHistory = histories[0];
            StudyReconcileDescriptorParser parser    = new StudyReconcileDescriptorParser();
            StudyReconcileDescriptor       changeLog = parser.Parse(lastHistory.ChangeDescription);

            switch (changeLog.Action)
            {
            case StudyReconcileAction.CreateNewStudy:
            case StudyReconcileAction.Merge:
                if (lastHistory.DestStudyStorageKey != null)
                {
                    preProcessingResult = MergeImage(changeLog.Action, file, lastHistory);
                }
                break;

            case StudyReconcileAction.Discard:
                preProcessingResult = new AutoReconcilerResult(StudyReconcileAction.Discard)
                {
                    DiscardImage = true
                };
                break;

            case StudyReconcileAction.ProcessAsIs:
                if (lastHistory.DestStudyStorageKey != null)
                {
                    preProcessingResult = ProcessImageAsIs(file, lastHistory);
                }
                break;

            default:
                throw new NotImplementedException();
            }
            return(preProcessingResult);
        }