/// <summary>
        /// Connect to the server and authenticate the user
        /// </summary>
        public eLoginEnum ConnectToServer(String AUserName,
                                          String APassword,
                                          out Int32 AProcessID,
                                          out String AWelcomeMessage,
                                          out Boolean ASystemEnabled,
                                          out String AError,
                                          out IPrincipal AUserInfo)
        {
            AError = "";
            String ConnectionError;

            AUserInfo       = null;
            ASystemEnabled  = false;
            AWelcomeMessage = string.Empty;
            AProcessID      = -1;

            try
            {
                FClientManager = TConnectionHelper.Connect();

                // register Client session at the PetraServer
                eLoginEnum ReturnValue = ConnectClient(AUserName, APassword,
                                                       out AProcessID,
                                                       out AWelcomeMessage,
                                                       out ASystemEnabled,
                                                       out ConnectionError,
                                                       out AUserInfo);

                if (ReturnValue != eLoginEnum.eLoginSucceeded)
                {
                    AError = ConnectionError;
                    return(ReturnValue);
                }
            }
            catch (System.Net.Sockets.SocketException)
            {
                return(eLoginEnum.eLoginServerNotReachable);
            }
            catch (Exception exp)
            {
                TLogging.Log(exp.ToString() + Environment.NewLine + exp.StackTrace, TLoggingType.ToLogfile);
                throw new EServerConnectionGeneralException(exp.ToString());
            }

            if (TClientSettings.RunAsStandalone)
            {
                FPollClientTasks = null;
            }
            else
            {
                //
                // start the PollClientTasks Thread (which needs to run as long as the Client is running)
                //
                FPollClientTasks = new TPollClientTasks(FClientID);
            }

            return(eLoginEnum.eLoginSucceeded);
        }
        /// <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;
        }
Esempio n. 3
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);
        }
        /// <summary>
        /// Connect to the server and authenticate the user
        /// </summary>
        public eLoginEnum ConnectToServer(String AUserName,
            String APassword,
            out Int32 AProcessID,
            out String AWelcomeMessage,
            out Boolean ASystemEnabled,
            out String AError,
            out IPrincipal AUserInfo)
        {
            AError = "";
            String ConnectionError;
            AUserInfo = null;
            ASystemEnabled = false;
            AWelcomeMessage = string.Empty;
            AProcessID = -1;

            try
            {
                FClientManager = TConnectionHelper.Connect();

                // register Client session at the PetraServer
                eLoginEnum ReturnValue = ConnectClient(AUserName, APassword,
                    out AProcessID,
                    out AWelcomeMessage,
                    out ASystemEnabled,
                    out ConnectionError,
                    out AUserInfo);

                if (ReturnValue != eLoginEnum.eLoginSucceeded)
                {
                    AError = ConnectionError;
                    return ReturnValue;
                }
            }
            catch (System.Net.Sockets.SocketException)
            {
                return eLoginEnum.eLoginServerNotReachable;
            }
            catch (Exception exp)
            {
                TLogging.Log(exp.ToString() + Environment.NewLine + exp.StackTrace, TLoggingType.ToLogfile);
                throw new EServerConnectionGeneralException(exp.ToString());
            }

            if (TClientSettings.RunAsStandalone)
            {
                FPollClientTasks = null;
            }
            else
            {
                //
                // start the PollClientTasks Thread (which needs to run as long as the Client is running)
                //
                FPollClientTasks = new TPollClientTasks(FClientID);
            }

            return eLoginEnum.eLoginSucceeded;
        }