コード例 #1
0
        public ActionResult Logout()
        {
            string message = string.Empty;

            try
            {
                message = "2";
                _logMessages.Append("User being logged out. Username " + Identity.UserName + ".");
                if (Identity != null)
                {
                    //log off of sap webi
                    if (!string.IsNullOrEmpty(Identity.SapToken) && !string.IsNullOrEmpty(Identity.BOSessionId))
                    {
                        bool response = _restClient.LogoffFromSAP(Identity.SapToken, Identity.BOSessionId);
                        if (response)
                        {
                            message = "2";
                        }
                        else
                        {
                            message = "3";
                        }
                    }

                    //Log off of tableau
                    if (!string.IsNullOrEmpty(Identity.TableauAuthTicket))
                    {
                        _tableauClient.SignOut(Identity.TableauAuthTicket);
                    }
                }
            }
            catch (Exception ex)
            {
                message = "3";
                _logMessages.Append("An Error occurred loggin out the user. Exception information " + ex.Message + ".");
                Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
            }
            _authManager.SignOut(Request, Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie);
            return(RedirectToAction("Login", "Default", new { id = message }));
        }