protected override bool Initialize()
        {
            if (_theProcessor == null)
            {
                // Force a read context to be opened.  When developing the retry mechanism
                // for startup when the DB was down, there were problems when the type
                // initializer for enumerated values were failng first.  For some reason,
                // when the database went back online, they would still give exceptions.
                // changed to force the processor to open a dummy DB connect and cause an
                // exception here, instead of getting to the enumerated value initializer.
                using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                {
                    readContext.Dispose();
                }

                var xp = new WorkQueueManagerExtensionPoint();
                IWorkQueueManagerExtensionPoint[] extensions = CollectionUtils.Cast <IWorkQueueManagerExtensionPoint>(xp.CreateExtensions()).ToArray();
                foreach (IWorkQueueManagerExtensionPoint extension in extensions)
                {
                    try
                    {
                        extension.OnInitializing(this);
                    }
                    catch (Exception)
                    {
                        ThreadRetryDelay = (int)_retryDelay.TotalMilliseconds;
                        return(false);
                    }
                }

                _theProcessor = new WorkQueueProcessor(_threadCount, ThreadStop, Name);
            }

            return(true);
        }
        public void Dispose()
        {
            try
            {
                if (!DirectoryUtility.DeleteIfEmpty(_backupDirectory))
                {
                    Platform.Log(LogLevel.Warn, "Some backup files can be found left in {0}", BackupDirectory);
                }

                if (Platform.IsLogLevelEnabled(LogLevel.Debug) && Directory.Exists(_tempDirectory))
                {
                    Platform.Log(LogLevel.Debug, "Deleting temp folder: {0}", _tempDirectory);
                }

                DirectoryUtility.DeleteIfEmpty(_tempDirectory);
            }
            finally
            {
                if (_updateContext != null)
                {
                    Rollback();
                }

                if (_readContext != null)
                {
                    _readContext.Dispose();
                    _readContext = null;
                }
                // reset the current context for the thread
                _current = _inheritFrom;
            }
        }
Exemplo n.º 3
0
        public void Initialize()
        {
            bool bInit = false;

            while (!bInit)
            {
                try
                {
                    // Force a read context to be opened.  When developing the retry mechanism
                    // for startup when the DB was down, there were problems when the type
                    // initializer for enumerated values were failng first.  For some reason,
                    // when the database went back online, they would still give exceptions.
                    // changed to force the processor to open a dummy DB connect and cause an
                    // exception here, instead of getting to the enumerated value initializer.
                    using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                    {
                        readContext.Dispose();
                    }
                    bInit = true;
                }
                catch (Exception e)
                {
                    Platform.Log(LogLevel.Warn, "Unexpected exception intializing {0} service: {1}", Name, e.Message);
                }
                if (!bInit)
                {
                    if (CheckStop(ThreadRetryDelay))
                    {
                        return;
                    }
                }
            }
        }
Exemplo n.º 4
0
 public void Dispose()
 {
     if (_readContext != null)
     {
         lock (_syncRoot)
         {
             if (_readContext != null)
             {
                 _readContext.Dispose();
                 _readContext = null;
             }
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Returns a list of the DICOM services supported by this plugin.
        /// </summary>
        /// <returns></returns>
        public override IList <SupportedSop> GetSupportedSopClasses()
        {
            if (_list == null)
            {
                // Load from the database the non-image sops that are current configured for this server partition.
                _list = new List <SupportedSop>();

                // Input parameters
                PartitionSopClassQueryParameters inputParms = new PartitionSopClassQueryParameters();
                inputParms.ServerPartitionKey = Partition.GetKey();

                // Do the query
                using (IReadContext read = _store.OpenReadContext())
                {
                    IQueryServerPartitionSopClasses broker     = read.GetBroker <IQueryServerPartitionSopClasses>();
                    IList <PartitionSopClass>       sopClasses = broker.Find(inputParms);
                    read.Dispose();

                    // Now process the SOP Class list
                    foreach (PartitionSopClass partitionSopClass in sopClasses)
                    {
                        if (partitionSopClass.Enabled &&
                            partitionSopClass.NonImage)
                        {
                            SupportedSop sop = new SupportedSop();

                            sop.SopClass = SopClass.GetSopClass(partitionSopClass.SopClassUid);
                            sop.SyntaxList.Add(TransferSyntax.ExplicitVrLittleEndian);
                            sop.SyntaxList.Add(TransferSyntax.ImplicitVrLittleEndian);

                            _list.Add(sop);
                        }
                    }
                }
            }

            return(_list);
        }