コード例 #1
0
        public User login()
        {
            // Get the service stub
            SessionService sessionService = SessionService.getService(connection);

            try
            {
                // Prompt for credentials until they are right, or until user
                // cancels
                String[] credentials = credentialManager.PromptForCredentials();
                while (true)
                {
                    try
                    {
                        // *****************************
                        // Execute the service operation
                        // *****************************
                        LoginResponse resp = sessionService.Login(credentials[0], credentials[1],
                                                                  credentials[2], credentials[3], "", credentials[4]);

                        return(resp.User);
                    }
                    catch (InvalidCredentialsException e)
                    {
                        credentials = credentialManager.GetCredentials(e);
                    }
                }
            }
            // User canceled the operation, don't need to tell him again
            catch (CanceledOperationException /*e*/) {}

            // Exit the application
            //System.exit(0);
            return(null);
        }
コード例 #2
0
ファイル: Session.cs プロジェクト: MaxttChen/web_tc_soa
        /**
         * Login to the Teamcenter Server
         *
         */
        public User login(string Username, string Password, string Group, string Role, string Locale, string SessionDiscriminator)
        {
            // Get the service stub
            SessionService sessionService = SessionService.getService(connection);


            try
            {
                // Prompt for credentials until they are right, or until user
                // cancels
                //String[] credentials = credentialManager.PromptForCredentials();
                String[] credentials = { "infodba", "infodba", "", "", "SoaAppX" };

                while (true)
                {
                    try
                    {
                        // *****************************
                        // Execute the service operation
                        // *****************************
                        //LoginResponse resp = sessionService.Login(credentials[0], credentials[1],
                        //        credentials[2], credentials[3], "", credentials[4]);
                        LoginResponse resp = sessionService.Login(Username, Password, Group, Role, Locale, SessionDiscriminator);

                        return(resp.User);
                    }
                    catch (InvalidCredentialsException e)
                    {
                        credentials = credentialManager.GetCredentials(e);
                    }
                }
            }
            // User canceled the operation, don't need to tell him again
            catch (CanceledOperationException /*e*/) { }

            // Exit the application
            //System.exit(0);
            return(null);
        }