Beispiel #1
0
 /// <summary>
 /// initialize connection parameters
 /// </summary>
 public void Init(string ACrossDomainURI, string AClientID)
 {
     DetermineServerIPAddress();
     FCrossDomainURL = "tcp://" + FServerIPAddr + ":" + FServerPort + "/" + ACrossDomainURI;
     FClientID = AClientID;
     TheConnector = this;
 }
Beispiel #2
0
 /// <summary>
 /// initialize connection parameters
 /// </summary>
 public void Init(string ACrossDomainURI, string AClientID)
 {
     DetermineServerIPAddress();
     FCrossDomainURL = "tcp://" + FServerIPAddr + ":" + FServerPort + "/" + ACrossDomainURI;
     FClientID       = AClientID;
     TheConnector    = this;
 }
        /// <summary>
        /// todoComment
        /// </summary>
        public bool ConnectToServer(String AUserName,
            String APassword,
            out Int32 AProcessID,
            out String AWelcomeMessage,
            out Boolean ASystemEnabled,
            out String AError,
            out IPrincipal AUserInfo)
        {
            AError = "";
            String ConnectionError;

            if (FConnector == null)
            {
                FConnector = (TConnector)Activator.CreateInstance(ConnectorType);
            }

            try
            {
                if (TAppSettingsManager.ConfigFileName.Length > 0)
                {
                    // connect to the PetraServer's ClientManager
                    FConnector.GetRemoteServerConnection(TAppSettingsManager.ConfigFileName, out FClientManager);
                }
                else
                {
                    // connect to the PetraServer's ClientManager
                    FConnector.GetRemoteServerConnection(Environment.GetCommandLineArgs()[0] + ".config", out FClientManager);
                }

                // register Client session at the PetraServer
                bool ReturnValue = ConnectClient(AUserName, APassword, FClientManager,
                    out AProcessID,
                    out AWelcomeMessage,
                    out ASystemEnabled,
                    out ConnectionError,
                    out AUserInfo);
                TRemoteBase.ClientManager = FClientManager;

                if (!ReturnValue)
                {
                    AError = ConnectionError;
                    return ReturnValue;
                }
            }
            catch (System.Net.Sockets.SocketException)
            {
                throw new EServerConnectionServerNotReachableException();
            }
            catch (EDBConnectionNotEstablishedException exp)
            {
                if (exp.Message.IndexOf("Access denied") != -1)
                {
                    // Prevent passing out stack trace in case the PetraServer cannot connect
                    // a Client (to make this happen, somebody would have tampered with the
                    // DB Password decryption routines...)
                    throw new EServerConnectionGeneralException("PetraServer misconfiguration!");
                }
                else
                {
                    throw;
                }
            }
            catch (EClientVersionMismatchException)
            {
                throw;
            }
            catch (ELoginFailedServerTooBusyException)
            {
                throw;
            }
            catch (Exception exp)
            {
                TLogging.Log(exp.ToString() + Environment.NewLine + exp.StackTrace, TLoggingType.ToLogfile);
                throw new EServerConnectionGeneralException(exp.ToString());
            }

            //
            // acquire .NET Remoting Proxy objects for remoted Server objects
            //

            FRemotePollClientTasks =
                (IPollClientTasksInterface)FConnector.GetRemoteObject(FRemotingURL_PollClientTasks, typeof(IPollClientTasksInterface));

            //
            // start the KeepAlive Thread (which needs to run as long as the Client is running)
            //
            FKeepAlive = new TEnsureKeepAlive();

            //
            // start the PollClientTasks Thread (which needs to run as long as the Client is running)
            //
            FPollClientTasks = new TPollClientTasks(FClientID, FRemotePollClientTasks);

            //
            // initialise object that holds references to all our remote object .NET Remoting Proxies
            //
            FRemote = new TRemoteBase(FClientManager);
            return true;
        }
Beispiel #4
0
        /// <summary>
        /// todoComment
        /// </summary>
        public bool ConnectToServer(String AUserName,
                                    String APassword,
                                    out Int32 AProcessID,
                                    out String AWelcomeMessage,
                                    out Boolean ASystemEnabled,
                                    out String AError,
                                    out IPrincipal AUserInfo)
        {
            AError = "";
            String ConnectionError;

            if (FConnector == null)
            {
                FConnector = (TConnector)Activator.CreateInstance(ConnectorType);
            }

            try
            {
                if (TAppSettingsManager.ConfigFileName.Length > 0)
                {
                    // connect to the PetraServer's ClientManager
                    FConnector.GetRemoteServerConnection(TAppSettingsManager.ConfigFileName, out FClientManager);
                }
                else
                {
                    // connect to the PetraServer's ClientManager
                    FConnector.GetRemoteServerConnection(Environment.GetCommandLineArgs()[0] + ".config", out FClientManager);
                }

                // register Client session at the PetraServer
                bool ReturnValue = ConnectClient(AUserName, APassword, FClientManager,
                                                 out AProcessID,
                                                 out AWelcomeMessage,
                                                 out ASystemEnabled,
                                                 out ConnectionError,
                                                 out AUserInfo);
                TRemoteBase.ClientManager = FClientManager;

                if (!ReturnValue)
                {
                    AError = ConnectionError;
                    return(ReturnValue);
                }
            }
            catch (System.Net.Sockets.SocketException)
            {
                throw new EServerConnectionServerNotReachableException();
            }
            catch (EDBConnectionNotEstablishedException exp)
            {
                if (exp.Message.IndexOf("Access denied") != -1)
                {
                    // Prevent passing out stack trace in case the PetraServer cannot connect
                    // a Client (to make this happen, somebody would have tampered with the
                    // DB Password decryption routines...)
                    throw new EServerConnectionGeneralException("PetraServer misconfiguration!");
                }
                else
                {
                    throw;
                }
            }
            catch (EClientVersionMismatchException)
            {
                throw;
            }
            catch (ELoginFailedServerTooBusyException)
            {
                throw;
            }
            catch (Exception exp)
            {
                TLogging.Log(exp.ToString() + Environment.NewLine + exp.StackTrace, TLoggingType.ToLogfile);
                throw new EServerConnectionGeneralException(exp.ToString());
            }

            //
            // acquire .NET Remoting Proxy objects for remoted Server objects
            //

            FRemotePollClientTasks =
                (IPollClientTasksInterface)FConnector.GetRemoteObject(FRemotingURL_PollClientTasks, typeof(IPollClientTasksInterface));

            //
            // start the KeepAlive Thread (which needs to run as long as the Client is running)
            //
            FKeepAlive = new TEnsureKeepAlive();

            //
            // start the PollClientTasks Thread (which needs to run as long as the Client is running)
            //
            FPollClientTasks = new TPollClientTasks(FClientID, FRemotePollClientTasks);

            //
            // initialise object that holds references to all our remote object .NET Remoting Proxies
            //
            FRemote = new TRemoteBase(FClientManager);
            return(true);
        }