Beispiel #1
0
        public void Initialize( )
        {
            try
            {
                DicomHelper      = new DicomHelpers( );
                DataAccessHelper = new DataAccessHelpers( );

                var storagePath    = DicomHelpers.GetTestDataFolder("storage", true);
                var mediaIdFactory = new DicomMediaIdFactory();


                MediaStorageService storageService = new FileStorageService(storagePath);

                var factory = new Pacs.Commands.DCloudCommandFactory(storageService,
                                                                     DataAccessHelper.DataAccess,
                                                                     new DicomMediaWriterFactory(storageService,
                                                                                                 mediaIdFactory),
                                                                     mediaIdFactory);

                StoreService = new ObjectStoreService(factory);
                QueryService = new ObjectArchieveQueryService(DataAccessHelper.DataAccess);

                PopulateData( );
            }
            catch (Exception)
            {
                Cleanup( );

                throw;
            }
        }
Beispiel #2
0
        public static void Start(int port, string aet)
        {
            AETitle = aet;
            string storageConection = ConfigurationManager.AppSettings["app:PacsStorageConnection"];

            if (storageConection.StartsWith("|datadirectory|", StringComparison.OrdinalIgnoreCase))
            {
                var appDataPath  = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                var lastIndex    = storageConection.IndexOf('|', 1);
                var userPathPart = storageConection.Substring(lastIndex + 1);
                storageConection = appDataPath + userPathPart;
            }
            IDicomMediaIdFactory mediaIdFactory = new DicomMediaIdFactory();
            DbSchemaProvider     schemaProvider = new StorageDbSchemaProvider();

            DatabaseService = new SqlDatabaseFactory(ConfigurationManager.AppSettings["app:PacsDataArchieve"]);

            IObjectArchieveDataAccess dataAccess =
                new ObjectArchieveDataAccess(
                    schemaProvider,
                    new ObjectArchieveDataAdapter(
                        schemaProvider,
                        DatabaseService
                        )
                    );

            IMediaStorageService storageService = new FileStorageService(storageConection);

            IDicomMediaWriterFactory dicomMediaWriterFactory =
                new DicomMediaWriterFactory(
                    storageService,
                    mediaIdFactory
                    );

            StorageService = new ObjectStoreService(
                new Pacs.Commands.DCloudCommandFactory(
                    storageService,
                    dataAccess,
                    dicomMediaWriterFactory,
                    mediaIdFactory
                    )
                );

            QueryService = new ObjectArchieveQueryService(dataAccess);

            RetrieveService = new ObjectRetrieveService(
                storageService,
                dicomMediaWriterFactory,
                mediaIdFactory
                );

            _server = DicomServer.Create <SCP>(port);
        }
Beispiel #3
0
        public void Initialize( )
        {
            DicomHelper      = new DicomHelpers( );
            DataAccessHelper = new DataAccessHelpers( );
            var storagePath    = DicomHelpers.GetTestDataFolder("storage", true);
            var mediaIdFactory = new DicomMediaIdFactory( );


            MediaStorageService storageService = new FileStorageService(storagePath);

            var factory = new Pacs.Commands.DCloudCommandFactory(storageService,
                                                                 DataAccessHelper.DataAccess,
                                                                 new DicomMediaWriterFactory(storageService,
                                                                                             mediaIdFactory),
                                                                 mediaIdFactory);

            StoreService = new ObjectStoreService(factory);
        }
        private static IObjectStoreService CreateStorageService(string storagePath, string databaseConnectionString)
        {
            IDicomMediaIdFactory      mediaIdFactory = new DicomMediaIdFactory( );
            IMediaStorageService      storageService = new FileStorageService(storagePath);
            DbSchemaProvider          schemaProvider = new StorageDbSchemaProvider( );
            IDatabaseFactory          databaseFacory = new SqlDatabaseFactory(databaseConnectionString);
            ObjectArchieveDataAdapter dataAdapter    = new ObjectArchieveDataAdapter(schemaProvider, databaseFacory);
            IObjectArchieveDataAccess dataAccess     = new ObjectArchieveDataAccess(databaseConnectionString,
                                                                                    schemaProvider,
                                                                                    dataAdapter);
            IDicomMediaWriterFactory mediaWriterFactory = new DicomMediaWriterFactory(storageService,
                                                                                      mediaIdFactory);
            IDCloudCommandFactory factory = new DCloudCommandFactory(storageService,
                                                                     dataAccess,
                                                                     mediaWriterFactory,
                                                                     mediaIdFactory);

            IObjectStoreService StoreService = new ObjectStoreService(factory);

            return(StoreService);
        }
        public void Initialize( )
        {
            DicomHelper      = new DicomHelpers( );
            DataAccessHelper = new DataAccessHelpers( );
            var storagePath    = DicomHelpers.GetTestDataFolder("storage", true);
            var mediaIdFactory = new DicomMediaIdFactory( );


            MediaStorageService         storageService = new FileStorageService(storagePath);
            IObjectArchieveQueryService queryService   = new ObjectArchieveQueryService(DataAccessHelper.DataAccess);

            var factory = new Pacs.Commands.DCloudCommandFactory(storageService,
                                                                 DataAccessHelper.DataAccess,
                                                                 new DicomMediaWriterFactory(storageService,
                                                                                             mediaIdFactory),
                                                                 mediaIdFactory);

            StoreService = new ObjectStoreService(factory);

            var urlProvider = new MockRetrieveUrlProvider();

            WebStoreService = new WebObjectStoreService(StoreService, urlProvider);
            WebQueryService = new QidoRsService(queryService, mediaIdFactory, storageService);
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            var log = new LoggerConfiguration().WriteTo.LiterateConsole().CreateLogger();

            var clientId      = "";
            var clientSecret  = "";
            var testFilePath  = @"";
            var outputWebsite = @"";

            var scopes = new[] { "data:read", "data:write", "bucket:create", "data:search", "bucket:read" };

            var bucketKey = "forgefun";

            var authService        = new AuthorizationService();
            var objectStoreService = new ObjectStoreService();
            var derivativeService  = new DerivativeService();


            var testfileName = Path.GetFileName(testFilePath);

            log.Information("Get an authorization Token");
            var authToken = authService.GenerateToken(clientId, clientSecret, scopes);

            log.Information("Set the tokens for our services");
            objectStoreService.SetToken(authToken);
            derivativeService.SetToken(authToken);


            log.Information("List existing buckets for this application");
            var buckets = objectStoreService.ListBuckets();

            if (!buckets.Contains(bucketKey))
            {
                log.Information("If the bucket dosn't exist create it");
                objectStoreService.CreateBucket(bucketKey);
            }

            log.Information("List the bucket contents");
            var objects = objectStoreService.ListBucketContents(bucketKey);

            if (!objects.Contains(testfileName))
            {
                log.Information("If the bucket dosn't already contain our file upload it");
                objectStoreService.UploadFile(bucketKey, testfileName, testFilePath);
            }

            log.Information("Get our the objectId for our file");
            var testFileObjectId = objectStoreService.GetFileObjectId(bucketKey, testfileName);

            bool processing = false;

            log.Information("Check if our files has Derivatives");
            var exisitingDerivatives = derivativeService.GetDerivatives(testFileObjectId);

            if (exisitingDerivatives == null || exisitingDerivatives.Any(d => d.OutputType == "svf"))
            {
                var views = new[] { "2d", "3d" };
                log.Information("Issues the Convert to SVF");
                derivativeService.ConvertToSvf(testFileObjectId, views);
                processing = true;
            }

            while (processing)
            {
                log.Information("Waiting 10 seconds");
                Thread.Sleep(TimeSpan.FromSeconds(10));
                var derivativesPercentageComplete = derivativeService.DerivativesPercentComplete(testFileObjectId);

                switch (derivativesPercentageComplete)
                {
                case -1:
                    throw new Exception("Unexpected Processing State");

                case 100:
                    processing = false;
                    break;

                default:
                    log.Information("{derivativesPercentageComplete}% complete", derivativesPercentageComplete);
                    break;
                }
            }

            var base64Urn       = DerivativeService.Base64EncodeObjectId(testFileObjectId);
            var viewerAuthToken = authService.GenerateToken(clientId, clientSecret, new [] { "data:read" });

            var webSiteBuilder = new WebsiteBuilder();

            log.Information("Build the website");
            webSiteBuilder.Build(base64Urn, viewerAuthToken, outputWebsite);
        }