Exemple #1
0
        static void Main(string[] args)
        {
            string instanceName = GetInstanceName(args);

            if (instanceName == null)
            {
                instanceName = Engine.DefaultServerName;
            }

            Console.WriteLine("Server starting...");
            DataphorServiceHost host = new DataphorServiceHost();

            host.InstanceName = instanceName;
            host.Start();
            try
            {
                Console.WriteLine("Server started.");
                Console.ReadLine();
            }
            finally
            {
                Console.WriteLine("Server stopping...");
                host.Stop();
            }
        }
        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;
            }
        }