예제 #1
0
        private void SendUpdate(AutoUpdateItem item)
        {
            AeInfo[] aes = _AccessAgent.GetRelatedAeTitles(item.SourceAE, UPDATE_RELATION);
            DicomScp scp = null;

            if (aes == null || aes.Length == 0)
            {
                return;
            }

            foreach (AeInfo ae in aes)
            {
                using (UpdateProcessor processor = new UpdateProcessor(Module.Options.UseCustomAE ? Module.Options.AutoUpdateAE : item.ClientAE))
                {
                    try
                    {
                        DicomCommandStatusType status = DicomCommandStatusType.Reserved4;

                        if (processor.Scu.IsConnected())
                        {
                            processor.Scu.CloseForced(true);
                        }
                        scp    = new DicomScp(IPAddress.Parse(ae.Address), ae.AETitle, ae.Port);
                        status = processor.SendUpdate(scp, item.Dicom, item.Action);
                        if (status != DicomCommandStatusType.Success)
                        {
                            if (status != DicomCommandStatusType.MissingAttribute && status != DicomCommandStatusType.AttributeOutOfRange)
                            {
                                AddRetry(scp, item, ae.Address);
                            }
                        }
                    }
                    catch (ClientAssociationException ce)
                    {
                        string message = string.Format("[Auto Update] Failed to establish association with server: {0}.  Adding {1} action to update retry queue.", ce.Reason,
                                                       AutoRetryProcessor.Actions[item.Action]);

                        UpdateProcessor.LogEvent(LogType.Error, MessageDirection.None, message, DicomCommandType.Undefined, null, processor.Scu, null);
                        AddRetry(scp, item, ae.Address);
                    }
                    catch (DicomException de)
                    {
                        string message = string.Format("[Auto Update] Error: {0}. Adding {1} action to update retry queue.", de.Message, AutoRetryProcessor.Actions[item.Action]);

                        UpdateProcessor.LogEvent(LogType.Error, MessageDirection.Input, message, DicomCommandType.Undefined, null, processor.Scu, null);
                        AddRetry(scp, item, ae.Address);
                    }
                    catch (Exception e)
                    {
                        string message = "[Auto Update] " + e.Message;

                        Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined,
                                          DateTime.Now, LogType.Error, MessageDirection.None, message, null, null);
                    }
                    finally
                    {
                    }
                }
            }
        }
예제 #2
0
 public static void AddRetry(DicomScp scp, AutoUpdateItem item, string ae)
 {
     if (Module.RetryProcessor != null)
     {
         Module.RetryProcessor.AddRetry(scp, item, ae);
     }
 }
예제 #3
0
 public void AddItem(AutoUpdateItem item)
 {
     lock (locker)
     {
         _TaskQueue.Enqueue(item);
         Monitor.PulseAll(locker);
     }
 }
예제 #4
0
        private void Process()
        {
            while (true)
            {
                AutoUpdateItem item = null;

                lock (locker)
                {
                    while (_TaskQueue.Count == 0)
                    {
                        Monitor.Wait(locker);
                    }
                    item = _TaskQueue.Dequeue();
                }

                if (item == null)
                {
                    break;
                }

                SendUpdate(item);
            }
        }