Beispiel #1
0
        public static UserInfo GetUserInfo(IAutomationEngineInstance engine)
        {
            var environmentSettings = new EnvironmentSettings();

            environmentSettings.Load();
            AuthMethods authMethods = new AuthMethods();

            authMethods.Initialize(environmentSettings.ServerType, environmentSettings.OrganizationName, environmentSettings.ServerUrl, environmentSettings.Username, environmentSettings.Password, environmentSettings.AgentId);

            var    sessionVariablesDict = engine.EngineContext.SessionVariables;
            object sessionUserInfo;

            bool keyExists = sessionVariablesDict.TryGetValue("UserInfo", out sessionUserInfo);

            if (!keyExists)
            {
                sessionUserInfo = authMethods.GetUserInfo();
                SetAuthSessionVariables(engine, (UserInfo)sessionUserInfo);
            }

            return((UserInfo)sessionUserInfo);
        }