Example #1
0
        private void RegisterGatewayServer()
        {
            GatewayServer gateway = GetGatewayServer( );

            if (gateway == null)
            {
                return;
            }

            GatewayServersManager serverManager = new GatewayServersManager(gateway);

            if (serverManager != null)
            {
                AeInfo remote = serverManager.GetRemoteServer();

                if (remote != null)
                {
                    StorageServerInformation info = GetStorageServerInfo();

                    if (info != null)
                    {
                        if (remote.Address == info.DicomServer.IPAddress &&
                            remote.Port == info.DicomServer.Port)
                        {
                            DicomServer server = ServiceLocator.Retrieve <DicomServer>();

                            GatewaySession.Log(string.Empty, string.Empty, -1, DicomCommandType.Undefined, LogType.Error, MessageDirection.None, null,
                                               "Gateway - Remote server cannot be the same as primary server.  Gateway [" + server.AETitle + "] not available.");
                            return;
                        }
                    }
                }
                ServiceLocator.Register <GatewayServersManager> (serverManager);
            }
        }
            private void AddAe ( AeInfo info )
            {
               try
               {
                  if ( InvokeRequired )
                  {
                     Invoke ( new MethodInvoker ( delegate ( ) 
                     {
                        AddAe ( info ) ;
                     } ) ) ;
                     
                     return ;
                  }
                  
                  ListViewItem item ;
                  
                  
                  item = AeTitlesListView.Items.Add ( info.AETitle ) ;

                  item.SubItems.Add ( info.Address ) ;
                  item.SubItems.Add ( info.Port.ToString ( ) ) ;
                  item.SubItems.Add ( info.SecurePort.ToString ( )  ) ;
                  
                  item.Tag = info ;
               }
               catch ( Exception exception )
               {
                  System.Diagnostics.Debug.Assert ( false, exception.Message ) ;
                                 
                  throw ;
               }
            }
            private void toolStripButtonAddAeTitle_Click ( object sender, EventArgs e )
            {
               try
               {
                  EditAeTitleDialog dialog ;
                  
                  
                  dialog = new EditAeTitleDialog ( ) ;

                  if ( dialog.ShowDialog ( this ) == DialogResult.OK )
                  {
                     AeInfo newAeInfo = AddInUtils.Clone<AeInfo> ( dialog.AeInfo ) ;
                     
                     
                     newAeInfo.Address = newAeInfo.Address ;
                     
                     try
                     {
                        WorkstationService.SendMessage ( MessageNames.AddAeTitle, newAeInfo ) ;
                     }
                     catch ( Exception ex )
                     {
                        ThreadSafeMessager.ShowError (  "Error sending message.\n" + ex.Message ) ;
                     }
                  }
               }
               catch ( Exception exception )
               {
                  System.Diagnostics.Debug.Assert ( false, exception.Message ) ;
                                 
                  ThreadSafeMessager.ShowError (  exception.Message ) ;
               }
            }
 public void AddAeTitle(AeInfo aetitle)
 {
     listViewAutoUpdate.ItemChecked -= listViewAutoUpdate_ItemChecked;
     comboBoxSource.Items.Add(aetitle);
     AddToList(aetitle);
     listViewAutoUpdate.ItemChecked += listViewAutoUpdate_ItemChecked;
 }
        private void MoveRow(int direction)
        {
            Gateways gateways = (Gateways)_gatewaySource.DataSource;

            Gateways.RemoteServerRow currentRow = ((Gateways.RemoteServerRow)(( DataRowView )_remoteServerSource.Current).Row);
            _remoteServerSource.Position += direction;
            Gateways.RemoteServerRow newRow = ((Gateways.RemoteServerRow)(( DataRowView )_remoteServerSource.Current).Row);
            AeInfo remoteServer             = (AeInfo)currentRow.RemoteServerSettings;
            int    currentIndex             = gateways.RemoteServer.Rows.IndexOf(currentRow);
            int    newIndex = gateways.RemoteServer.Rows.IndexOf(newRow);

            object[] items = currentRow.ItemArray;

            gateways.RemoteServer.Rows.Remove(currentRow);
            DataRow updateRow = gateways.RemoteServer.NewRow( );

            updateRow.ItemArray = items;
            gateways.RemoteServer.Rows.InsertAt(updateRow, newIndex);
            _remoteServerSource.Position = newIndex;

            GatewayServer server = ( GatewayServer )((Gateways.GatewayServerRow)(( DataRowView )_gatewaySource.Current).Row).GatewayServer;

            int aeInfoIndex = server.RemoteServers.IndexOf(remoteServer);

            aeInfoIndex += direction;
            server.RemoteServers.Remove(remoteServer);
            server.RemoteServers.Insert(aeInfoIndex, remoteServer);

            GatewaySettingsPresenter.SetGatwayServerAddInSettings(server);
        }
Example #6
0
        private static List <DicomScp> GetScps(string[] aetitles)
        {
            List <DicomScp> scps    = new List <DicomScp>();
            IAETitle        aetitle = ServiceLocator.Retrieve <IAETitle>();

            foreach (string ae in aetitles)
            {
                try
                {
                    AeInfo info = aetitle.GetAeInfo(ae);

                    if (info != null && !string.IsNullOrEmpty(info.Address))
                    {
#if LEADTOOLS_V20_OR_LATER
                        // Update dbo.AeInfo.LastAccessDate to Date.Now
                        info.LastAccessDate = DateTime.Now;
                        aetitle.Update(info.AETitle, info);
#endif

                        DicomScp scp = new DicomScp(ResolveIPAddress(info.Address), ae, info.Port);

                        scps.Add(scp);
                    }
                }
                catch (Exception e)
                {
                    Logger.Global.SystemException(string.Empty, e);
                }
            }
            return(scps);
        }
Example #7
0
        private QueryRetrieveScu GetScu(AeInfo server)
        {
            QueryRetrieveScu scu           = null;
            bool             useSecurePort = (server.Port == 0) && (server.SecurePort != 0);
            int port = useSecurePort ? server.SecurePort : server.Port;

            if (useSecurePort)
            {
                GatewaySession.InitializeDicomSecurity(false);
                scu = new QueryRetrieveScu(string.Empty, DicomNetSecurityMode.Tls, GatewaySession._openSslOptions);
                scu.UseSecureHost = true;
                GatewaySession.SetCiphers(scu);
            }

            if (scu == null)
            {
                scu = new QueryRetrieveScu();
            }

            scu.AETitle     = server.AETitle;
            scu.HostAddress = IPAddress.Parse(server.Address);
            scu.HostPort    = port;

            return(scu);
        }
        private void EditAeTitleDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                if (_AeInfo == null)
                {
                    _AeInfo = new AeInfo();
                }

                _AeInfo.AETitle    = AETitleTextBox.Text;
                _AeInfo.Address    = HostNameTextBox.Text;
                _AeInfo.Port       = Convert.ToInt32(PortNumericUpDown.Value);
                _AeInfo.SecurePort = Convert.ToInt32(SecurePortNumericUpDown.Value);

                if (comboBoxClientPortSelection.SelectedItem is ClientPortUsageType)
                {
                    ClientPortUsageType clientPortUsage = (ClientPortUsageType)comboBoxClientPortSelection.SelectedItem;

                    if (clientPortUsage != ClientPortUsageType.None)
                    {
                        _AeInfo.ClientPortUsage = clientPortUsage;
                    }
                }

                _AeInfo.LastAccessDate = DateTime.Now;
            }
        }
        private void AddToList(AeInfo info)
        {
            ListViewItem item = new ListViewItem(info.AETitle);

            item.SubItems.Add(info.Address);
            item.SubItems.Add(info.Port.ToString());
            item.Tag = info;
            listViewAutoUpdate.Items.Add(item);
        }
Example #10
0
        //private void LoadAeTitles()
        //{
        //   AeInfo[] aetitles = _AccessAgent.GetAeTitles();

        //   forwardManager.SetAeTitles(aetitles);
        //}

        private void AddToList(AeInfo info)
        {
            //ListViewItem item = new ListViewItem(info.AETitle);

            //item.SubItems.Add(info.Address);
            //item.SubItems.Add(info.Port.ToString());
            //item.Tag = info;
            //listViewAutoCopy.Items.Add(item);
        }
Example #11
0
        private DicomScp GetScp(AeInfo client)
        {
            int port = (client.Port != 0) ? client.Port : client.SecurePort;

            return(new DicomScp(IPAddress.Parse(client.Address), client.AETitle, port)
            {
                Timeout = GatewaySession.Timeout
            });
        }
            private void UpdateAe 
            ( 
               string oldAe, 
               AeInfo info, 
               bool failed
            )
            {
               try
               {
                  if ( InvokeRequired )
                  {
                     Invoke ( new MethodInvoker ( delegate ( ) 
                     {
                        UpdateAe ( oldAe, info, failed ) ;
                     } ) ) ;
                     
                     return ;
                  }
                  
                  foreach ( ListViewItem item in AeTitlesListView.Items )
                  {
                     AeInfo old ;
                     
                     
                     old = item.Tag as AeInfo ;

                     if (old.AETitle == oldAe)
                     {
                        //
                        // If the update didn't fail we will update the display
                        //
                        if ( !failed )
                        {
                           item.Text = info.AETitle;
                           item.SubItems [ 1 ].Text = info.Address ;
                           item.SubItems [ 2 ].Text = info.Port.ToString ( ) ;
                           item.SubItems [ 3 ].Text = info.SecurePort.ToString ( ) ;
                           
                           item.Tag = info ;
                        }
                        
                        break ;
                     }
                  }
                  
                  HandleStatusChange ( ) ;
               }
               catch ( Exception exception )
               {
                  System.Diagnostics.Debug.Assert ( false, exception.Message ) ;
                                 
                  throw ;
               }
            }
Example #13
0
        private static AeInfo GetScp(PACSConnection server)
        {
            AeInfo scpInfo;

            scpInfo = new AeInfo( );

            scpInfo.AETitle = server.AETitle;
            scpInfo.Address = server.IPAddress;
            scpInfo.Port    = server.Port;

            return(scpInfo);
        }
Example #14
0
        private AeInfo GetScu(ClientConnection client)
        {
            AeInfo scuInfo;


            scuInfo = new AeInfo( );

            scuInfo.AETitle = (client == null || string.IsNullOrEmpty(client.AETitle)) ? LocalClient.AETitle : client.AETitle;
            scuInfo.Address = LocalClient.IPAddress;
            scuInfo.Port    = LocalClient.Port;

            return(scuInfo);
        }
        public void UpdateClient(string oldAe, AeInfo aetitle)
        {
            if (oldAe != aetitle.AETitle)
            {
                int index = comboBoxForwardTo.Items.IndexOf(oldAe);

                if (index != -1)
                {
                    comboBoxForwardTo.Items[index]     = aetitle.AETitle;
                    comboBoxToolForwardTo.Items[index] = aetitle.AETitle;
                }
            }
        }
        private void GetRelatedAes(AeInfo info)
        {
            AeInfo[] aes = _AccessAgent.GetRelatedAeTitles(info.AETitle, UPDATE_RELATION);

            foreach (AeInfo ae in aes)
            {
                ListViewItem item = listViewAutoUpdate.Items.Cast <ListViewItem>().Where(i => i.Text == ae.AETitle).FirstOrDefault();

                if (item != null)
                {
                    item.Checked = true;
                }
            }
        }
Example #17
0
        private void EditAeTitleDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                if (_AeInfo == null)
                {
                    _AeInfo = new AeInfo();
                }

                _AeInfo.AETitle    = AETitleTextBox.Text;
                _AeInfo.Address    = HostNameTextBox.Text;
                _AeInfo.Port       = Convert.ToInt32(PortNumericUpDown.Value);
                _AeInfo.SecurePort = Convert.ToInt32(SecurePortNumericUpDown.Value);
            }
        }
Example #18
0
        public EditAeTitleDialog(AeInfo info)
        {
            InitializeComponent();
            _AeInfo = info;
            if (_AeInfo == null)
            {
                Text = Resources.AddAeTitle;
            }
            else
            {
                Text = Resources.EditAeTitle;
            }

            InitializeStrings();
            Icon = Resources.ApplicationIcon;
        }
            private void toolStripButtonEditAeTitle_Click ( object sender, EventArgs e )
            {
               try
               {
                  EditAeTitleDialog dialog ;
                  string oldAe ;
                  
                  
                  if ( AeTitlesListView.SelectedItems.Count == 0 )
                  {
                     return ;
                  }
                  
                  dialog = new EditAeTitleDialog ( ) ;
                  
                  dialog.AeInfo = AddInUtils.Clone<AeInfo> ( AeTitlesListView.SelectedItems [ 0 ].Tag as AeInfo ) ;
                  
                  oldAe  = dialog.AeInfo.AETitle ;

                  if ( dialog.ShowDialog ( this ) == DialogResult.OK )
                  {
                     try
                     {
                        AeInfo newAeInfo = AddInUtils.Clone<AeInfo> ( dialog.AeInfo ) ;
                        
                        
                        newAeInfo.Address = newAeInfo.Address ;
                        
                        WorkstationService.SendMessage ( MessageNames.UpdateAeTitle,
                                                         oldAe, 
                                                         newAeInfo ) ;
                     }
                     catch (Exception ex)
                     {
                        ThreadSafeMessager.ShowError (  "Error sending message.\n" + ex.Message ) ;
                     }
                  }
               }
               catch ( Exception exception )
               {
                  System.Diagnostics.Debug.Assert ( false, exception.Message ) ;
                                 
                  ThreadSafeMessager.ShowError (  exception.Message ) ;
               }
            }
        public void RemoveAeTitle(string aetitle)
        {
            int index = -1;

            foreach (AeInfo info in comboBoxSource.Items)
            {
                if (info.AETitle == aetitle)
                {
                    index = comboBoxSource.Items.IndexOf(info);
                    break;
                }
            }

            if (index != -1)
            {
                listViewAutoUpdate.ItemChecked -= listViewAutoUpdate_ItemChecked;
                comboBoxSource.Items.RemoveAt(index);
                index = -1;
                foreach (ListViewItem item in listViewAutoUpdate.Items)
                {
                    AeInfo i = item.Tag as AeInfo;

                    if (i.AETitle == aetitle)
                    {
                        index = item.Index;
                        break;
                    }
                }

                if (index != -1)
                {
                    listViewAutoUpdate.Items.RemoveAt(index);
                }
                listViewAutoUpdate.ItemChecked += listViewAutoUpdate_ItemChecked;

                if (_SelectedItem != null)
                {
                    if ((_SelectedItem.Tag as AeInfo).AETitle == aetitle)
                    {
                        _SelectedItem  = null;
                        _SelectedIndex = 0;
                    }
                }
            }
        }
Example #21
0
        private void comboBoxSource_SelectionChangeCommitted(object sender, EventArgs e)
        {
            AeInfo info;

            if (comboBoxSource.SelectedItem == null)
            {
                return;
            }

            info = comboBoxSource.SelectedItem as AeInfo;

            listViewAutoCopy.ItemChecked -= listViewAutoUpdate_ItemChecked;
            listViewAutoCopy.Check(false);
            try
            {
                listViewAutoCopy.Enabled = checkBoxAutoCopy.Checked;
                if (_SelectedItem != null)
                {
                    listViewAutoCopy.Items.Insert(_SelectedIndex, _SelectedItem);
                }

                foreach (ListViewItem item in listViewAutoCopy.Items)
                {
                    AeInfo i = item.Tag as AeInfo;

                    if (i.Address == info.Address && i.AETitle == info.AETitle)
                    {
                        _SelectedItem  = item;
                        _SelectedIndex = listViewAutoCopy.Items.IndexOf(item);
                        break;
                    }
                }

                if (_SelectedItem != null)
                {
                    listViewAutoCopy.Items.Remove(_SelectedItem);
                }
                GetRelatedAes(info);
            }
            finally
            {
                listViewAutoCopy.ItemChecked += listViewAutoUpdate_ItemChecked;
            }
        }
        private void listViewAutoUpdate_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            AeInfo info = comboBoxSource.SelectedItem as AeInfo;

            if (null == info)
            {
                return;
            }

            if (e.Item.Checked)
            {
                _AccessAgent.AddReleation(info.AETitle, e.Item.Text, UPDATE_RELATION);
            }
            else
            {
                _AccessAgent.RemoveRelation(info.AETitle, e.Item.Text, UPDATE_RELATION);
            }
            OnSetIsDirty(sender, e);
        }
Example #23
0
        public void Add(AeInfo aeInfo)
        {
            if (aeInfo is AeInfoExtended)
            {
                _Agent.Add(aeInfo as AeInfoExtended);
            }
            else
            {
                AeInfoExtended extended = new AeInfoExtended();

                extended.Address = aeInfo.Address;
                extended.AETitle = aeInfo.AETitle;
                extended.Port    = aeInfo.Port;
                // extended.UseSecurePort = aeInfo.SecurePort != 0;
                extended.SecurePort      = aeInfo.SecurePort;
                extended.ClientPortUsage = aeInfo.ClientPortUsage;
#if LEADTOOLS_V20_OR_LATER
                extended.LastAccessDate = aeInfo.LastAccessDate;
#endif
                _Agent.Add(extended);
            }
        }
Example #24
0
        private void EditAeTitleDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                if (_AeInfo == null)
                {
                    _AeInfo = new AeInfo();
                }

                _AeInfo.AETitle = AETitle.Text;
                if (radioButtonHost.Checked)
                {
                    _AeInfo.Address = Hostname.Text;
                }
                else
                {
                    _AeInfo.Address = textboxIPAddress.Text;
                }
                _AeInfo.Port       = Convert.ToInt32(Port.Value);
                _AeInfo.SecurePort = Convert.ToInt32(SecurePort.Value);
            }
        }
Example #25
0
        public void Update(string AETitle, AeInfo newInfo)
        {
            if (newInfo is AeInfoExtended)
            {
                _Agent.Update(AETitle, newInfo as AeInfoExtended);
            }
            else
            {
                AeInfoExtended extended = new AeInfoExtended();

                extended.Address = newInfo.Address;
                extended.AETitle = newInfo.AETitle;
                extended.Port    = newInfo.Port;
                // extended.UseSecurePort = newInfo.SecurePort != 0;
                extended.ClientPortUsage = newInfo.ClientPortUsage;
                extended.SecurePort      = newInfo.SecurePort;
#if LEADTOOLS_V20_OR_LATER
                extended.LastAccessDate = newInfo.LastAccessDate;
#endif
                _Agent.Update(AETitle, extended);
            }
        }
Example #26
0
        public string VerifyConnection(PACSConnection server, ClientConnection client)
        {
            AeInfo scpInfo = GetScp(server);

            using (StoreScu scu = new StoreScu())
            {
                DicomScp scp = new DicomScp(IPAddress.Parse(scpInfo.Address), scpInfo.AETitle, scpInfo.Port);

                scu.AETitle = client.AETitle;
                try
                {
                    if (scu.Verify(scp))
                    {
                        return(string.Empty);
                    }
                }
                catch (Exception exception)
                {
                    return(exception.Message);
                }
            }
            return(string.Empty);
        }
Example #27
0
 public ClientAddedEventArgs(AeInfo newClient)
 {
     _NewClient = newClient;
 }
Example #28
0
 public ClientUpdatedEventArgs(string oldae, AeInfo client)
 {
     _OldAe  = oldae;
     _Client = client;
 }
Example #29
0
        public AeInfo GetAeInfo(string AETitle)
        {
            AeInfo info = _Agent.GetAeTitle(AETitle);

            return(info);
        }
Example #30
0
 public QueryProcessor(AeInfo scpInfo, AeInfo scuInfo)
 {
     ScuInfo = scuInfo;
     ScpInfo = scpInfo;
 }