public void GetEnumerator_ExecutionTime_IsNotSlow()
        {
            DicomDictionary.EnsureDefaultDictionariesLoaded();

            var millisecondsPerCall = TimeCall(1000, () => Assert.NotNull(DicomDictionary.Default.Last()));

            var referenceDictionarySize = DicomDictionary.Default.Count();
            var referenceTime           = TimeCall(1000, () => Assert.NotEqual(0, Enumerable.Range(0, referenceDictionarySize).ToDictionary(i => 2 * i).Values.Last()));

            _output.WriteLine($"GetEnumerator: {millisecondsPerCall} ms per call, reference time: {referenceTime} ms per call");

            Assert.InRange(millisecondsPerCall, 0, (1 + referenceTime) * 5);
        }
Beispiel #2
0
        protected override void OnLoad(EventArgs e)
        {
            DicomDictionary.EnsureDefaultDictionariesLoaded(ModifierKeys != Keys.Shift);

            var args = Environment.GetCommandLineArgs();

            if (args.Length > 1)
            {
                OpenFile(args[1]);
            }

            base.OnLoad(e);
        }
        /// <inheritdoc />
        /// <exception cref="DicomNetworkException">If the service is already listening.</exception>
        /// <exception cref="System.Net.Sockets.SocketException">If another service is already listening on this socket.</exception>
        public bool StartServer(int port, Func <IReadOnlyDictionary <DicomUID, DicomTransferSyntax[]> > getAcceptedTransferSyntaxes, TimeSpan timeout)
        {
            if (!ApplicationEntityValidationHelpers.ValidatePort(port))
            {
                throw new ArgumentException("The port is not valid.", nameof(port));
            }

            // Check if we are already listening
            if (IsListening)
            {
                throw new DicomNetworkException("We are already listening. Please call stop server before starting.");
            }

            // Looks like StartServer has been called before but failed to start listening.
            // Lets dispose of the current instance and try again.
            if (_dicomServer != null)
            {
                DisposeDicomServer();
            }

            var fileStoreParameters = new DicomFileStoreParameters(DicomDataReceiverUpdate, getAcceptedTransferSyntaxes, _dicomSaver);

            // Preload dictionary to prevent timeouts
            DicomDictionary.EnsureDefaultDictionariesLoaded();

            // Constructing the listener dicom server will attempt to start the service.
            _dicomServer = DicomServer.Create <ListenerDicomService>(ipAddress: "localhost", port: port, userState: fileStoreParameters);

            // Wait until listening or we have an exception.
            SpinWait.SpinUntil(() => _dicomServer.IsListening || _dicomServer.Exception != null, timeout);

            if (_dicomServer.Exception != null)
            {
                // Throw any exceptions
                throw _dicomServer.Exception;
            }

            return(_dicomServer?.IsListening ?? false);
        }
Beispiel #4
0
        public MainViewModel()
        {
            // todo: choose a better place to initialize the fo-dicom?
            DicomDictionary.EnsureDefaultDictionariesLoaded(true);

            configurationService.Load();

            CurrentConfiguration = configurationService.GetConfiguration();

            SearchPathHistory  = new ObservableCollection <string>(CurrentConfiguration.SearchPathHistory ?? new List <string>());
            FileTypesHistory   = new ObservableCollection <string>(CurrentConfiguration.FileTypesHistory ?? new List <string>());
            SopClassUidHistory = new ObservableCollection <string>(CurrentConfiguration.SopClassUidHistory ?? new List <string>());
            DicomTagHistory    = new ObservableCollection <string>(CurrentConfiguration.DicomTagHistory ?? new List <string>());
            SearchTextHistory  = new ObservableCollection <string>(CurrentConfiguration.SearchTextHistory ?? new List <string>());

            SearchPath        = CurrentConfiguration.SearchCriteria.SearchPath;
            FileTypes         = CurrentConfiguration.SearchCriteria.FileTypes;
            SopClassUid       = CurrentConfiguration.SearchCriteria.SearchSopClassUid;
            Tag               = CurrentConfiguration.SearchCriteria.SearchTag;
            SearchText        = CurrentConfiguration.SearchCriteria.SearchText;
            CaseSensitive     = CurrentConfiguration.SearchCriteria.CaseSensitive;
            WholeWord         = CurrentConfiguration.SearchCriteria.WholeWord;
            IncludeSubfolders = CurrentConfiguration.SearchCriteria.IncludeSubfolders;
            //SearchInResults = CurrentConfiguration.SearchCriteria.SearchInResults;
            SearchThreads = Math.Min(CurrentConfiguration.SearchCriteria.SearchThreads, Environment.ProcessorCount);

            CPULogicCores = new ObservableCollection <int>(GetCPULogicCoresList());

            this.searchService.FileListCompleted += SearchService_FileListCompleted;

            this.searchService.OnLoadDicomFile += SearchService_OnLoadDicomFile;

            this.searchService.OnCompletDicomFile += SearchService_OnCompletDicomFile;

            this.searchService.OnSearchComplete += SearchService_OnSearchComplete;
        }