当前位置: 首页>>代码示例>>C#>>正文


C# Command.CommandProcessor类代码示例

本文整理汇总了C#中ClearCanvas.Dicom.Utilities.Command.CommandProcessor的典型用法代码示例。如果您正苦于以下问题:C# CommandProcessor类的具体用法?C# CommandProcessor怎么用?C# CommandProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CommandProcessor类属于ClearCanvas.Dicom.Utilities.Command命名空间,在下文中一共展示了CommandProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnExecute

		protected override void OnExecute(CommandProcessor theProcessor)
		{
			Platform.CheckForNullReference(Context, "Context");
			Platform.CheckForNullReference(Context.ReconcileWorkQueueData, "Context.ReconcileWorkQueueData");

			foreach (WorkQueueUid uid in Context.WorkQueueUidList)
			{

			    string imagePath = GetReconcileUidPath(uid);

				try
				{
					using (var processor = new ServerCommandProcessor(String.Format("Deleting {0}", uid.SopInstanceUid)))
					{
						var deleteFile = new FileDeleteCommand(imagePath, true);
						var deleteUid = new DeleteWorkQueueUidCommand(uid);
						processor.AddCommand(deleteFile);
						processor.AddCommand(deleteUid);
						Platform.Log(ServerPlatform.InstanceLogLevel, deleteFile.ToString());
						if (!processor.Execute())
						{
							throw new Exception(String.Format("Unable to discard image {0}", uid.SopInstanceUid));
						}
					}
				}
				catch (Exception e)
				{
					Platform.Log(LogLevel.Error, e, "Unexpected exception discarding file: {0}", imagePath);
					SopInstanceProcessor.FailUid(uid, true);
				}
			}
		}
开发者ID:nhannd,项目名称:Xian,代码行数:32,代码来源:DiscardImagesCommand.cs

示例2: OnExecute

		/// <summary>
		/// Execute the command
		/// </summary>
		/// <param name="updateContext">Database update context.</param>
		/// <param name="theProcessor">The processor executing the command.</param>
		protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
		{
		    var columns = new ArchiveStudyStorageUpdateColumns
		                      {
		                          ArchiveTime = Platform.Time,
		                          PartitionArchiveKey = _partitionArchiveKey,
		                          StudyStorageKey = _studyStorageKey,
		                          ArchiveXml = _archiveXml,
		                          ServerTransferSyntaxKey = _serverTransferSyntaxKey
		                      };


		    var insertBroker = updateContext.GetBroker<IArchiveStudyStorageEntityBroker>();

			ArchiveStudyStorage storage = insertBroker.Insert(columns);


		    var parms = new UpdateArchiveQueueParameters
		                    {
		                        ArchiveQueueKey = _archiveQueueKey,
		                        ArchiveQueueStatusEnum = ArchiveQueueStatusEnum.Completed,
		                        ScheduledTime = Platform.Time,
		                        StudyStorageKey = _studyStorageKey
		                    };


		    var broker = updateContext.GetBroker<IUpdateArchiveQueue>();

            if (!broker.Execute(parms))
                throw new ApplicationException("InsertArchiveStudyStorageCommand failed");
		}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:36,代码来源:InsertArchiveStudyStorageCommand.cs

示例3: OnExecute

		protected override void OnExecute(CommandProcessor theProcessor)
		{
		    if (!File.Exists(_path))
			{
				Platform.Log(LogLevel.Error, "Unexpected error finding file to add to XML {0}", _path);
				throw new ApplicationException("Unexpected error finding file to add to XML {0}" + _path);
			}

			var finfo = new FileInfo(_path);
			long fileSize = finfo.Length;

			var dicomFile = new DicomFile(_path);
			dicomFile.Load(DicomReadOptions.StorePixelDataReferences | DicomReadOptions.Default);

		    _sopInstanceUid = dicomFile.DataSet[DicomTags.SopInstanceUid];
		    _seriesInstanceUid = dicomFile.DataSet[DicomTags.SeriesInstanceUid];

			// Setup the insert parameters
			if (false == _stream.AddFile(dicomFile, fileSize))
			{
				Platform.Log(LogLevel.Error, "Unexpected error adding SOP to XML Study Descriptor for file {0}",
				             _path);
				throw new ApplicationException("Unexpected error adding SOP to XML Study Descriptor for SOP: " +
				                               dicomFile.MediaStorageSopInstanceUid);
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:26,代码来源:InsertInstanceXmlCommand.cs

示例4: OnExecute

        protected override void OnExecute(CommandProcessor theProcessor)
        {
            Backup();

            _studyStorageLocation.SaveStudyXml(_studyXml, out _fileCreated);
            _fileCreated = true;
        }
开发者ID:nhannd,项目名称:Xian,代码行数:7,代码来源:SaveStudyXmlCommand.cs

示例5: OnExecute

		/// <summary>
		/// Do the unzip.
		/// </summary>
		protected override void OnExecute(CommandProcessor theProcessor)
		{
			using (ZipFile zip = new ZipFile(_zipFile))
			{
				zip.ExtractAll(_destinationFolder,_overwrite);
			}
		}
开发者ID:nhannd,项目名称:Xian,代码行数:10,代码来源:ExtractZipCommand.cs

示例6: OnExecute

		protected override void OnExecute(CommandProcessor theProcessor)
		{
            if (String.IsNullOrEmpty(_directory) && GetDirectoryDelegate!=null)
            {
                _directory = GetDirectoryDelegate();
            }

			if (Directory.Exists(_directory))
			{
				_created = false;
				return;
			}

			try
			{
			    Directory.CreateDirectory(_directory);
			}
            catch(UnauthorizedAccessException)
            {
                //alert the system admin
                //ServerPlatform.Alert(AlertCategory.System, AlertLevel.Critical, "Filesystem", 
                //                        AlertTypeCodes.NoPermission, null, TimeSpan.Zero,
                //                     "Unauthorized access to {0} from {1}", _directory, ServerPlatform.HostId);
                throw;
            }

			_created = true;
		}
开发者ID:nhannd,项目名称:Xian,代码行数:28,代码来源:CreateDirectoryCommand.cs

示例7: OnExecute

		protected override void OnExecute(CommandProcessor theProcessor)
		{
            Platform.CheckTrue(File.Exists(_sourceFile), String.Format("Source file '{0}' doesn't exist", _sourceFile));
            
            if (File.Exists(_destinationFile))
            {
                if (_failIfExists)
                    throw new ApplicationException(String.Format("Destination file already exists: {0}", _destinationFile));
            }

            if (RequiresRollback)
                Backup();

		    FileUtils.Copy(_sourceFile, _destinationFile, !_failIfExists);

		    try
		    {
                if ((File.GetAttributes(_destinationFile) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                    File.SetAttributes(_destinationFile, FileAttributes.Normal);
		    }
		    catch (Exception)
		    { }

            // Will check for existance
            FileUtils.Delete(_sourceFile);
            
		    _sourceRenamed = true;
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:28,代码来源:RenameFileCommand.cs

示例8: OnExecute

        protected override void OnExecute(CommandProcessor theProcessor)
        {
            if (Context.ContextStudy == null)
            {
                var broker = DataAccessContext.GetStudyBroker();
                Context.ContextStudy = broker.GetStudy(_studyInstanceUid);

                if (Context.ContextStudy == null)
                {
                    // This is a bit of a hack to handle batch processing of studies
                    Context.ContextStudy = _location.Study;
                    broker.AddStudy(Context.ContextStudy);
                }
            }

            //Only update the store time if the study is actively being received/imported.
            if (_reason == UpdateReason.LiveImport || Context.ContextStudy.StoreTime == null)
                Context.ContextStudy.StoreTime = Platform.Time;

            if (_reason != UpdateReason.SopsDeleted)
            {
                //Only update these if the study is being updated in an "additive" way (import/receive/re-index).
                //A series deletion, for example, should not update these.
                Context.ContextStudy.Deleted = false;
                Context.ContextStudy.Reindex = false;
            }

            Context.ContextStudy.Update(_studyXml);
        }
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:29,代码来源:InsertOrUpdateStudyCommand.cs

示例9: OnExecute

        protected override void OnExecute(CommandProcessor theProcessor)
        {
            if (_commands!=null)
            {
	            var sq = new OriginalAttributesSequence
		            {
			            ModifiedAttributesSequence = new DicomSequenceItem(),
			            ModifyingSystem = ProductInformation.Component,
			            ReasonForTheAttributeModification = "CORRECT",
			            AttributeModificationDatetime = Platform.Time,
			            SourceOfPreviousValues = _file.SourceApplicationEntityTitle
		            };

	            foreach (BaseImageLevelUpdateCommand command in _commands)
                {
                    if (!command.Apply(_file, sq))
                        throw new ApplicationException(
                            String.Format("Unable to update the duplicate sop. Command={0}", command));
                }

				var sqAttrib = _file.DataSet[DicomTags.OriginalAttributesSequence] as DicomAttributeSQ;
				if (sqAttrib != null)
					sqAttrib.AddSequenceItem(sq.DicomSequenceItem);
            }
            
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:26,代码来源:UpdateDuplicateSopCommand.cs

示例10: OnExecute

		/// <summary>
		/// Do the work.
		/// </summary>
		protected override void OnExecute(CommandProcessor theProcessor)
		{
			using (var zipService = Platform.GetService<IZipService>())
			{
			    zipService.OpenWrite(_zipFile);
                zipService.ForceCompress = HsmSettings.Default.CompressZipFiles;
                zipService.TempFileFolder = _tempFolder;
                zipService.Comment = String.Format("Archive for study {0}", _studyXml.StudyInstanceUid);

				// Add the studyXml file
                zipService.AddFile(Path.Combine(_studyFolder, String.Format("{0}.xml", _studyXml.StudyInstanceUid)), String.Empty);

				// Add the studyXml.gz file
                zipService.AddFile(Path.Combine(_studyFolder, String.Format("{0}.xml.gz", _studyXml.StudyInstanceUid)), String.Empty);

			    string uidMapXmlPath = Path.Combine(_studyFolder, "UidMap.xml");
                if (File.Exists(uidMapXmlPath))
                    zipService.AddFile(uidMapXmlPath, String.Empty);

				// Add each sop from the StudyXmlFile
				foreach (SeriesXml seriesXml in _studyXml)
					foreach (InstanceXml instanceXml in seriesXml)
					{
						string filename = Path.Combine(_studyFolder, seriesXml.SeriesInstanceUid);
						filename = Path.Combine(filename, String.Format("{0}.dcm", instanceXml.SopInstanceUid));

                        zipService.AddFile(filename, seriesXml.SeriesInstanceUid);
					}

                zipService.Save();
			}
		}
开发者ID:tcchau,项目名称:ClearCanvas,代码行数:35,代码来源:CreateStudyZipCommand.cs

示例11: OnExecute

        protected override void OnExecute(CommandProcessor theProcessor)
        {
            if (Context.ContextStudy == null)
            {
                var broker = DataAccessContext.GetStudyBroker();
                Context.ContextStudy = broker.GetStudy(_studyInstanceUid);

                if (Context.ContextStudy == null)
                {
                    // This is a bit of a hack to handle batch processing of studies
                    Context.ContextStudy = _location.Study;
                    broker.AddStudy(Context.ContextStudy);
                }
            }

            //Only update the store time if the study is actively being received/imported.
            if (_reason == UpdateReason.LiveImport || Context.ContextStudy.StoreTime == null)
                Context.ContextStudy.StoreTime = Platform.Time;

            if (_reason != UpdateReason.SopsDeleted)
            {
                //Only update these if the study is being updated in an "additive" way (import/receive/re-index).
                //A series deletion, for example, should not update these.
                Context.ContextStudy.Deleted = false;
                Context.ContextStudy.Reindex = false;
            }

            Context.ContextStudy.Update(_studyXml);

			// TODO (2014-01-11) Rigel - Deal with this better in the database, converted due to ticket #11593
	        if (Context.ContextStudy.StudyDate < (DateTime)SqlDateTime.MinValue)
		        Context.ContextStudy.StudyDate = null;
			if (Context.ContextStudy.PatientsBirthDate < (DateTime)SqlDateTime.MinValue)
				Context.ContextStudy.PatientsBirthDate = null;
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:35,代码来源:InsertOrUpdateStudyCommand.cs

示例12: OnExecute

		protected override void OnExecute(CommandProcessor theProcessor)
        {
            try
            {
                if (Directory.Exists(_dir))
                {
                    if (DeleteOnlyIfEmpty && !DirectoryUtility.IsEmpty(_dir))
                    {
                        return;
                    }

                    if (Log)
                        Platform.Log(LogLevel.Info, "Deleting {0}", _dir);

                    Directory.Move(_dir, _dir +".deleted");
                    _sourceDirRenamed = true;
                }
                
            }
            catch (Exception ex)
            {
                if (_failIfError)
                    throw;
            	// ignore it
            	Platform.Log(LogLevel.Warn, ex, "Unexpected exception occurred when deleting {0}. It is ignored.", _dir);
            }
        }
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:27,代码来源:DeleteDirectoryCommand.cs

示例13: OnExecute

		/// <summary>
		/// Do the work.
		/// </summary>
		protected override void OnExecute(CommandProcessor theProcessor)
		{
			using (var zip = new ZipFile(_zipFile))
			{
				zip.ForceNoCompression = !HsmSettings.Default.CompressZipFiles;
				zip.TempFileFolder = _tempFolder;
				zip.Comment = String.Format("Archive for study {0}", _studyXml.StudyInstanceUid);
				zip.UseZip64WhenSaving = Zip64Option.AsNecessary;

				// Add the studyXml file
				zip.AddFile(Path.Combine(_studyFolder,String.Format("{0}.xml",_studyXml.StudyInstanceUid)), String.Empty);

				// Add the studyXml.gz file
				zip.AddFile(Path.Combine(_studyFolder, String.Format("{0}.xml.gz", _studyXml.StudyInstanceUid)), String.Empty);

			    string uidMapXmlPath = Path.Combine(_studyFolder, "UidMap.xml");
                if (File.Exists(uidMapXmlPath))
                    zip.AddFile(uidMapXmlPath, String.Empty);

				// Add each sop from the StudyXmlFile
				foreach (SeriesXml seriesXml in _studyXml)
					foreach (InstanceXml instanceXml in seriesXml)
					{
						string filename = Path.Combine(_studyFolder, seriesXml.SeriesInstanceUid);
						filename = Path.Combine(filename, String.Format("{0}.dcm", instanceXml.SopInstanceUid));

						zip.AddFile(filename, seriesXml.SeriesInstanceUid);
					}

				zip.Save();
			}
		}
开发者ID:nhannd,项目名称:Xian,代码行数:35,代码来源:CreateStudyZipCommand.cs

示例14: OnExecute

        protected override void OnExecute(CommandProcessor theProcessor)
        {
            long fileSize = 0;
            if (File.Exists(_file.Filename))
            {
                var finfo = new FileInfo(_file.Filename);
                fileSize = finfo.Length;
            }

            String seriesInstanceUid = _file.DataSet[DicomTags.SeriesInstanceUid].GetString(0, string.Empty);
            String sopInstanceUid = _file.DataSet[DicomTags.SopInstanceUid].GetString(0, string.Empty);

            if (_studyXml.Contains(seriesInstanceUid,sopInstanceUid))
            {
                _duplicate = true;                
            }

            // Setup the insert parameters
            if (false == _studyXml.AddFile(_file, fileSize, _settings))
            {
                Platform.Log(LogLevel.Error, "Unexpected error adding SOP to XML Study Descriptor for file {0}",
                             _file.Filename);
                throw new ApplicationException("Unexpected error adding SOP to XML Study Descriptor for SOP: " +
                                               _file.MediaStorageSopInstanceUid);
            }

            if (_writeFile)
            {
                // Write it back out.  We flush it out with every added image so that if a failure happens,
                // we can recover properly.
                bool fileCreated;
                _studyStorageLocation.SaveStudyXml(_studyXml, out fileCreated);
            }
        }
开发者ID:nhannd,项目名称:Xian,代码行数:34,代码来源:InsertStudyXmlCommand.cs

示例15: OnExecute

	    /// <summary>
	    /// Execute the insert.
	    /// </summary>
	    /// <param name="theProcessor">The command processor calling us</param>
	    /// <param name="updateContext">The persistent store connection to use for the update.</param>
	    protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
		{
			var locInsert = updateContext.GetBroker<IInsertStudyStorage>();
	        var insertParms = new InsertStudyStorageParameters
	                              {
	                                  ServerPartitionKey = _serverPartitionKey,
	                                  StudyInstanceUid = _studyInstanceUid,
	                                  Folder = _folder,
	                                  FilesystemKey = _filesystemKey,
	                                  QueueStudyStateEnum = QueueStudyStateEnum.Idle
	                              };

	        if (_transfersyntax.LosslessCompressed)
			{
				insertParms.TransferSyntaxUid = _transfersyntax.UidString;
				insertParms.StudyStatusEnum = StudyStatusEnum.OnlineLossless;
			}
			else if (_transfersyntax.LossyCompressed)
			{
				insertParms.TransferSyntaxUid = _transfersyntax.UidString;
				insertParms.StudyStatusEnum = StudyStatusEnum.OnlineLossy;
			}
			else
			{
                insertParms.TransferSyntaxUid = _transfersyntax.UidString;
				insertParms.StudyStatusEnum = StudyStatusEnum.Online;
			}

			// Find one so we don't uselessly process all the results.
			_location = locInsert.FindOne(insertParms);
		}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:36,代码来源:InsertFilesystemStudyStorageCommand.cs


注:本文中的ClearCanvas.Dicom.Utilities.Command.CommandProcessor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。