Beispiel #1
0
        public Server GetServer()
        {
            CheckTestConfiguration();

            Server LServer = new Server();

            FTestConfiguration.ApplyTo(LServer);
            return(LServer);
        }
Beispiel #2
0
        public DataFhirServer(string instanceName)
        {
            if (String.IsNullOrEmpty(instanceName))
            {
                throw new ArgumentNullException("instanceName");
            }

            _instanceName  = instanceName;
            _configuration = InstanceManager.GetInstance(instanceName);             // Don't necessarily need this to come from the instance manager, but this is the easiest solution for now
            _server        = new DAEServer.Server();
            _configuration.ApplyTo((DAEServer.Server)_server);
            _server.Start();
        }
        public void Start()
        {
            if (!IsActive)
            {
                try
                {
                    InstanceManager.Load();

                    ServerConfiguration instance = InstanceManager.Instances[_instanceName];
                    if (instance == null)
                    {
                        // Establish a default configuration
                        instance = ServerConfiguration.DefaultInstance(_instanceName);
                        InstanceManager.Instances.Add(instance);
                        InstanceManager.Save();
                    }

                    _server = new Server();
                    instance.ApplyTo(_server);
                    _remoteServer = new RemoteServer(_server);
                    _nativeServer = new NativeServer(_server);
                    _server.Start();
                    try
                    {
                        _server.LogMessage("Creating WCF Service...");
                        _service = new DataphorService(_remoteServer);

                        _server.LogMessage("Creating Native CLI Service...");
                        _nativeService = new NativeCLIService(_nativeServer);

                        _server.LogMessage("Configuring Service Host...");
                        _serviceHost = instance.UseServiceConfiguration ? new CustomServiceHost(_service) : new ServiceHost(_service);

                        if (!instance.UseServiceConfiguration)
                        {
                            _serviceHost.AddServiceEndpoint
                            (
                                typeof(IDataphorService),
                                DataphorServiceUtility.GetBinding(),
                                DataphorServiceUtility.BuildInstanceURI(Environment.MachineName, instance.PortNumber, instance.Name)
                            );
                        }

                        _server.LogMessage("Opening Service Host...");
                        _serviceHost.Open();

                        _server.LogMessage("Configuring Native CLI Service Host...");
                        _nativeServiceHost = instance.UseServiceConfiguration ? new CustomServiceHost(_nativeService) : new ServiceHost(_nativeService);

                        if (!instance.UseServiceConfiguration)
                        {
                            _nativeServiceHost.AddServiceEndpoint
                            (
                                typeof(INativeCLIService),
                                DataphorServiceUtility.GetBinding(),
                                DataphorServiceUtility.BuildNativeInstanceURI(Environment.MachineName, instance.PortNumber, instance.Name)
                            );
                        }

                        _server.LogMessage("Opening Native CLI Service Host...");
                        _nativeServiceHost.Open();

                        // Start the listener
                        if (instance.ShouldListen)
                        {
                            _server.LogMessage("Starting Listener Service...");
                            _listenerServiceHost = new ListenerServiceHost(instance.OverrideListenerPortNumber, instance.RequireSecureListenerConnection, instance.AllowSilverlightClients, instance.UseServiceConfiguration);
                        }
                    }
                    catch (Exception exception)
                    {
                        _server.LogError(exception);
                        throw;
                    }
                }
                catch
                {
                    Stop();
                    throw;
                }
            }
        }
        public ServerConnection(ServerAlias serverAlias, bool autoStart)
        {
            if (serverAlias == null)
            {
                throw new ClientException(ClientException.Codes.ServerAliasRequired);
            }

            _serverAlias = serverAlias;
            InProcessAlias  inProcessAlias  = _serverAlias as InProcessAlias;
            ConnectionAlias connectionAlias = _serverAlias as ConnectionAlias;

            try
            {
                if (inProcessAlias != null)
                {
                                        #if !SILVERLIGHT
                    if (inProcessAlias.IsEmbedded)
                    {
                        ServerConfiguration configuration = InstanceManager.GetInstance(inProcessAlias.InstanceName);
                        _hostedServer = new Server.Server();
                        configuration.ApplyTo(_hostedServer);
                        if (autoStart)
                        {
                            _hostedServer.Start();
                        }
                    }
                    else
                    {
                        _serviceHost = new DataphorServiceHost();
                        _serviceHost.InstanceName = inProcessAlias.InstanceName;
                        if (autoStart)
                        {
                            _serviceHost.Start();
                        }
                    }
                                        #else
                    throw new NotSupportedException("In-process aliases are not supported in Silverlight");
                                        #endif
                }
                else
                {
                    _clientServer =
                        String.IsNullOrEmpty(connectionAlias.ClientConfigurationName)
                                                        ?
                        new ClientServer
                        (
                            connectionAlias.HostName,
                            connectionAlias.InstanceName,
                            connectionAlias.OverridePortNumber,
                            connectionAlias.SecurityMode,
                            connectionAlias.OverrideListenerPortNumber,
                            connectionAlias.ListenerSecurityMode
                        )
                                                        :
                        new ClientServer
                        (
                            connectionAlias.HostName,
                            connectionAlias.ClientConfigurationName
                        );

                    _localServer = new LocalServer(_clientServer, connectionAlias.ClientSideLoggingEnabled, TerminalServiceUtility.ClientName);
                }
            }
            catch
            {
                CleanUp();
                throw;
            }
        }