예제 #1
0
        public void Accept()
        {
            ServerAE       = ServerAE.Trim();
            ServerName     = ServerName.Trim();
            ServerLocation = ServerLocation.Trim();
            ServerHost     = ServerHost.Trim();

            if (base.HasValidationErrors)
            {
                this.ShowValidation(true);
            }
            else
            {
                var current          = _serverTree.CurrentNode;
                var allButCurrent    = _serverTree.RootServerGroup.GetAllServers().Where(s => s != current).Cast <IServerTreeDicomServer>();
                var sameAETitleCount = allButCurrent.Count(s => s.AETitle == _serverAE);
                if (sameAETitleCount > 0)
                {
                    var message = sameAETitleCount == 1
                                      ? SR.ConfirmAETitleConflict_OneServer
                                      : String.Format(SR.ConfirmAETitleConflict_MultipleServers, sameAETitleCount);

                    if (DialogBoxAction.No == Host.DesktopWindow.ShowMessageBox(message, MessageBoxActions.YesNo))
                    {
                        return;
                    }
                }

                var newServer = new ServerTreeDicomServer(
                    _serverName,
                    _serverLocation,
                    _serverHost,
                    _serverAE,
                    _serverPort,
                    _isStreaming,
                    _headerServicePort,
                    _wadoServicePort);

                // edit current server
                if (_serverTree.CurrentNode.IsServer)
                {
                    _serverTree.ReplaceDicomServerInCurrentGroup(newServer);
                }
                // add new server
                else if (_serverTree.CurrentNode.IsServerGroup)
                {
                    ((IServerTreeGroup)_serverTree.CurrentNode).AddChild(newServer);
                    _serverTree.CurrentNode = newServer;
                }

                _serverTree.Save();

                SetServerNodeMetaProperties(_serverName, _isPriorsServer);

                _serverTree.FireServerTreeUpdatedEvent();

                this.ExitCode = ApplicationComponentExitCode.Accepted;
                Host.Exit();
            }
        }