Esempio n. 1
0
        public ForwardProcess(ForwardOptions options, string ae)
        {
            _Options  = options;
            _ServerAE = ae;

            Module.InitializeDicomSecurity(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the AdvancedSettingsChanged event of the server control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks>
        /// If the forwarding options changed we need to reinitialize the forwarding engine.
        /// </remarks>
        void server_AdvancedSettingsChanged(object sender, EventArgs e)
        {
            ForwardOptions   options;
            AdvancedSettings settings = AdvancedSettings.Open(_serviceDirectory);

            if (settings != null)
            {
                settings.RefreshSettings();
                options = settings.GetAddInCustomData <ForwardOptions>(ForwardManagerPresenter._addinName, "ForwardOptions");
                if (Options == null && options == null)
                {
                    options = new ForwardOptions();
                }
                Options = options;
                if (JobManager != null)
                {
                    JobManager.Stop();
                    if (IsLicenseValid())
                    {
                        JobManager.Start(Options);
                    }
                }
            }

            // Reinitialize the dicom security settings
            InitializeDicomSecurity(true);
        }
Esempio n. 3
0
 public JobManager(ForwardOptions options, IForwardDataAccessAgent fagent, IAeManagementDataAccessAgent aagent, IStorageDataAccessAgent sagent)
 {
     _Options      = options;
     _forwardAgent = fagent;
     _aeAgent      = aagent;
     _storageAgent = sagent;
 }
Esempio n. 4
0
 public HeartbeatService(ILogger <HeartbeatService> logger, IMemoryCache cache, IOptions <ForwardOptions> options)
 {
     _logger              = logger;
     _tokenSource         = new CancellationTokenSource();
     _tcpClients          = new HashSet <TcpClient>();
     _heartbeatTcpClients = new HashSet <HeartbeatTcpClient>();
     _cache          = cache;
     _forwardOptions = options.Value;
     _okBuff         = Encoding.ASCII.GetBytes("1");
 }
Esempio n. 5
0
        private void RegisterForwardService( )
        {
            ForwardOptions forwardOptions = __Settings.GetAddInCustomData <ForwardOptions>(ForwardManagerPresenter._addinName, "ForwardOptions");

            if (forwardOptions == null)
            {
                forwardOptions = new ForwardOptions();
            }

            if (null != forwardOptions)
            {
                ServiceLocator.Register <ForwardOptions> (forwardOptions);
            }
        }
Esempio n. 6
0
File: E2ETest.cs Progetto: genlu/cli
    private static void Forward(int bufferSize, ForwardOptions options, string str, string expectedCaptured, string[] expectedWrites)
    {
        var forwarder = new StreamForwarder(bufferSize);
        var writes    = new List <string>();

        if ((options & ForwardOptions.WriteLine) != 0)
        {
            forwarder.ForwardTo(
                write: (options & ForwardOptions.Write) == 0 ? (Action <string>)null : writes.Add,
                writeLine: s => writes.Add(s + "\n"));
        }
        if ((options & ForwardOptions.Capture) != 0)
        {
            forwarder.Capture();
        }
        forwarder.Read(new StringReader(str));
        Assert.Equal(expectedWrites, writes);
        var captured = forwarder.GetCapturedOutput();

        Assert.Equal(expectedCaptured, captured);
    }
Esempio n. 7
0
        private void TestCapturingAndForwardingHelper(ForwardOptions options, string str, string expectedCaptured, string[] expectedWrites)
        {
            var forwarder = new StreamForwarder();
            var writes    = new List <string>();

            if ((options & ForwardOptions.WriteLine) != 0)
            {
                forwarder.ForwardTo(writeLine: s => writes.Add(s + Environment.NewLine));
            }
            if ((options & ForwardOptions.Capture) != 0)
            {
                forwarder.Capture();
            }

            forwarder.Read(new StringReader(str));
            Assert.Equal(expectedWrites, writes);

            var captured = forwarder.CapturedOutput;

            Assert.Equal(expectedCaptured, captured);
        }
Esempio n. 8
0
        public void Start(ForwardOptions options)
        {
            try
            {
                _AeInfo = _aeAgent.GetAeTitle(options.ForwardTo);
                if (_AeInfo != null)
                {
                    IPAddress address = IPAddress.None;

                    if (!IPAddress.TryParse(_AeInfo.Address, out address))
                    {
                        IPHostEntry host = Dns.GetHostEntry(_AeInfo.Address);

                        if (host.AddressList.Length > 0)
                        {
                            address = host.AddressList[0];
                        }
                    }

                    _Scp = new DicomScp(address, _AeInfo.AETitle, _AeInfo.Port);
                    if (options.Forward != null)
                    {
                        FixUpJob(options.Forward);
                        Scheduler.SubmitJob(options.Forward, new Action <Job>(Forward));
                    }

                    if (options.Clean != null)
                    {
                        FixUpJob(options.Clean);
                        Scheduler.SubmitJob(options.Clean, new Action <Job>(Clean));
                    }
                }
                _Options = options;
            }
            catch { }
        }
Esempio n. 9
0
        public ForwardOptions Clone(ForwardOptions options)
        {
            try
            {
                //
                // Don't serialize a null object, simply return the default for that object
                //

                if (Object.ReferenceEquals(options, null))
                {
                    return(null);
                }

                if (!options.GetType().IsSerializable)
                {
                    throw new ArgumentException("The type must be serializable.", "source");
                }

                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = new MemoryStream();

                using (stream)
                {
                    formatter.Serialize(stream, options);
                    stream.Seek(0, SeekOrigin.Begin);

                    return((ForwardOptions)formatter.Deserialize(stream));
                }
            }
            finally
            {
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
            }
        }
Esempio n. 10
0
 private static void Forward(int bufferSize, ForwardOptions options, string str, string expectedCaptured, string[] expectedWrites)
 {
     var forwarder = new StreamForwarder(bufferSize);
     var writes = new List<string>();
     if ((options & ForwardOptions.WriteLine) != 0)
     {
         forwarder.ForwardTo(
             write: (options & ForwardOptions.Write) == 0 ? (Action<string>)null : writes.Add,
             writeLine: s => writes.Add(s + "\n"));
     }
     if ((options & ForwardOptions.Capture) != 0)
     {
         forwarder.Capture();
     }
     forwarder.Read(new StringReader(str));
     Assert.Equal(expectedWrites, writes);
     var captured = forwarder.GetCapturedOutput();
     Assert.Equal(expectedCaptured, captured);
 }
Esempio n. 11
0
 public CleanProcess(ForwardOptions options, string ae)
 {         
    _Options = options;
    _ServerAE = ae;
 }
Esempio n. 12
0
        private void TestCapturingAndForwardingHelper(ForwardOptions options, string str, string expectedCaptured, string[] expectedWrites)
        {
            var forwarder = new StreamForwarder();
            var writes = new List<string>();

            if ((options & ForwardOptions.WriteLine) != 0)
            {
                forwarder.ForwardTo(writeLine: s => writes.Add(s + Environment.NewLine));
            }
            if ((options & ForwardOptions.Capture) != 0)
            {
                forwarder.Capture();
            }

            forwarder.Read(new StringReader(str));
            Assert.Equal(expectedWrites, writes);

            var captured = forwarder.CapturedOutput;
            Assert.Equal(expectedCaptured, captured);
        }
Esempio n. 13
0
 public ListeningService(IServiceProvider lifetime, IOptions <ForwardOptions> options, ILogger <ListeningService> logger)
 {
     this._lifetime = lifetime;
     this._logger   = logger;
     this._settings = options.Value;
 }
Esempio n. 14
0
        private void OnSendCStoreResponse(object sender, CStoreResponseSentEventArgs response)
        {
            try
            {
                bool process = false;


                lock ( _instancesListLock )
                {
                    process = (__MovedInstances.Contains(response.Instance) && !__ForwardedInstances.Contains(response.Instance));
                }

                if (process && response.Status == DicomCommandStatusType.Success)
                {
                    if (ServiceLocator.IsRegistered <ForwardOptions> ( ) && DataAccessServices.IsDataAccessServiceRegistered <IForwardDataAccessAgent> ( ))
                    {
                        ForwardOptions          forwardOptions = ServiceLocator.Retrieve <ForwardOptions> ( );
                        IForwardDataAccessAgent dataAccess     = DataAccessServices.GetDataAccessService <IForwardDataAccessAgent> ( );

                        if (null != forwardOptions && null != dataAccess)
                        {
                            DateTime?expires     = null;
                            DateTime forwardDate = DateTime.Now;


                            if (dataAccess.IsForwarded(response.Instance))
                            {
                                return;
                            }

                            if (forwardOptions.ImageHold != null && forwardOptions.ImageHold != 0)
                            {
                                switch (forwardOptions.HoldInterval)
                                {
                                case HoldInterval.Days:
                                {
                                    expires = forwardDate.AddDays(forwardOptions.ImageHold.Value);
                                }
                                break;

                                case HoldInterval.Months:
                                {
                                    expires = forwardDate.AddMonths(forwardOptions.ImageHold.Value);
                                }
                                break;

                                default:
                                {
                                    expires = forwardDate.AddYears(forwardOptions.ImageHold.Value);
                                }

                                break;
                                }
                            }

                            dataAccess.SetInstanceForwarded(response.Instance, forwardDate, expires);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GatewaySession.Log(__Client, DicomCommandType.CMove, LogType.Error, MessageDirection.Output, null, "[Gateway] Failed to set instance forwarding.\n" + ex.Message);
            }
        }
Esempio n. 15
0
        public override void Load(string serviceDirectory, string displayName)
        {
            IForwardDataAccessAgent      forwardAgent;
            IAeManagementDataAccessAgent aeAgent;
            IStorageDataAccessAgent      storageAgent;
            AdvancedSettings             settings = AdvancedSettings.Open(serviceDirectory);

            RegisterServerEvents(settings);
            _serviceDirectory = serviceDirectory;

            DicomServer server = ServiceLocator.Retrieve <DicomServer>();

            ServiceName = server.Name;
            _Timeout    = server.ClientTimeout <= 0 ? 30 : server.ClientTimeout;

            try
            {
                Options = settings.GetAddInCustomData <ForwardOptions>(ForwardManagerPresenter._addinName, "ForwardOptions");
                if (Options == null)
                {
                    Options = new ForwardOptions();
                }
            }
            catch (Exception e)
            {
                if (Options == null)
                {
                    Options = new ForwardOptions();
                }

                Logger.Global.Error(Source, e.Message);
            }

            StorageConfigManager = new StorageModuleConfigurationManager(true);
            StorageConfigManager.Load(ServiceDirectory);
            System.Configuration.Configuration configuration = DicomDemoSettingsManager.GetGlobalPacsAddinsConfiguration(serviceDirectory);
            if (!DataAccessServices.IsDataAccessServiceRegistered <IForwardDataAccessAgent>())
            {
                forwardAgent = DataAccessFactory.GetInstance(new ForwardDataAccessConfigurationView(configuration, null, displayName)).CreateDataAccessAgent <IForwardDataAccessAgent>();
                DataAccessServices.RegisterDataAccessService <IForwardDataAccessAgent>(forwardAgent);
            }
            else
            {
                forwardAgent = DataAccessServices.GetDataAccessService <IForwardDataAccessAgent>();
            }

            if (!DataAccessServices.IsDataAccessServiceRegistered <IAeManagementDataAccessAgent>())
            {
                aeAgent = DataAccessFactory.GetInstance(new AeManagementDataAccessConfigurationView(configuration, null, displayName)).CreateDataAccessAgent <IAeManagementDataAccessAgent>();
                DataAccessServices.RegisterDataAccessService <IAeManagementDataAccessAgent>(aeAgent);
            }
            else
            {
                aeAgent = DataAccessServices.GetDataAccessService <IAeManagementDataAccessAgent>();
            }

            _aeManagementAgent = aeAgent;

            if (!DataAccessServices.IsDataAccessServiceRegistered <IStorageDataAccessAgent>())
            {
                storageAgent = DataAccessFactory.GetInstance(new StorageDataAccessConfigurationView(configuration, null, displayName)).CreateDataAccessAgent <IStorageDataAccessAgent>();
                DataAccessServices.RegisterDataAccessService <IStorageDataAccessAgent>(storageAgent);
            }
            else
            {
                storageAgent = DataAccessServices.GetDataAccessService <IStorageDataAccessAgent>();
            }

            JobManager          = new JobManager(Options, forwardAgent, aeAgent, storageAgent);
            JobManager.ServerAE = _ServerAE;
            if (IsLicenseValid())
            {
                JobManager.Start();
            }
        }
Esempio n. 16
0
 public ClientServer(IServiceProvider lifetime, IOptions <ForwardOptions> options, ILogger <ClientServer> logger)
 {
     this._lifetime = lifetime;
     this._settings = options.Value;
     this._logger   = logger;
 }