public bool CanAccessDatabase(out string error)
        {
            error = string.Empty;
            try
            {
                System.Configuration.Configuration configuration = DicomDemoSettingsManager.GetGlobalPacsAddinsConfiguration(Module.ServiceDirectory);

                IForwardDataAccessAgent      forwardAgent      = GetAgent <IForwardDataAccessAgent>(configuration, new ForwardDataAccessConfigurationView(configuration, null, Module.ServiceName));
                IStorageDataAccessAgent      storageAgent      = GetAgent <IStorageDataAccessAgent>(configuration, new StorageDataAccessConfigurationView(configuration, null, Module.ServiceName));
                IAeManagementDataAccessAgent aeManagementAgent = GetAgent <IAeManagementDataAccessAgent>(configuration, new AeManagementDataAccessConfigurationView(configuration, null, Module.ServiceName));

                bool bContinue = true;
                if (forwardAgent == null)
                {
                    error     = string.Format("{0} {1}", AssemblyName, "Cannot create IForwardDataAccessAgent");
                    bContinue = false;
                }

                if (bContinue)
                {
                    if (storageAgent == null)
                    {
                        error     = string.Format("{0} {1}", AssemblyName, "Cannot create IStorageDataAccessAgent");
                        bContinue = false;
                    }
                }

                if (bContinue)
                {
                    if (aeManagementAgent == null)
                    {
                        error     = string.Format("{0} {1}", AssemblyName, "Cannot create IAeManagementDataAccessAgent");
                        bContinue = false;
                    }
                }

                if (bContinue)
                {
                    forwardAgent.IsForwarded("notUsed");

                    storageAgent.MaxQueryResults = 10;
                    storageAgent.IsPatientsExists("patientIdNotUsed");

                    aeManagementAgent.GetAeTitle("notUsed");
                }
            }
            catch (Exception e)
            {
                error = string.Format("{0} {1}", AssemblyName, e.Message);
            }

            bool ret = string.IsNullOrEmpty(error);

            return(ret);
        }
Exemple #2
0
        public bool CanAccessDatabase(out string error)
        {
            error = string.Empty;
            bool ret = false;

            try
            {
                System.Configuration.Configuration configuration = DicomDemoSettingsManager.GetGlobalPacsAddinsConfiguration(GatewaySession.ServiceDirectory);

                IForwardDataAccessAgent forwardAgent = GetAgent <IForwardDataAccessAgent>(configuration, new ForwardDataAccessConfigurationView(configuration, null, GatewaySession.ServiceName));
                IOptionsDataAccessAgent optionsAgent = GetAgent <IOptionsDataAccessAgent>(configuration, new OptionsDataAccessConfigurationView(configuration, null, GatewaySession.ServiceName));

                bool bContinue = true;
                if (forwardAgent == null)
                {
                    error     = string.Format("{0} {1}", AssemblyName, "Cannot create IForwardDataAccessAgent");
                    bContinue = false;
                }

                if (bContinue)
                {
                    if (optionsAgent == null)
                    {
                        error     = string.Format("{0} {1}", AssemblyName, "Cannot create IOptionsDataAccessAgent");
                        bContinue = false;
                    }
                }

                if (bContinue)
                {
                    forwardAgent.IsForwarded("notUsed");
                    optionsAgent.GetDefaultOptions();
                }
            }
            catch (Exception e)
            {
                error = string.Format("{0} {1}", AssemblyName, e.Message);
            }

            ret = string.IsNullOrEmpty(error);
            return(ret);
        }
Exemple #3
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);
            }
        }