public ActionResult Logout() { #region [ Add data into language combo box ] if (TempData.Keys.Contains(StaticContent.LanguageKey)) { LanguageKey temp = (LanguageKey)(TempData[StaticContent.LanguageKey]); initLanguageComboBox(temp.ToString()); } else { initLanguageComboBox(); } #endregion string str_IpAddr = this.HttpContext.Request.UserHostAddress; string str_HostName = this.HttpContext.Request.UserHostName; string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource("LoginScreentTitle"); string strError = MultilingualHelper.GetStringFromResource("I003"); string str_SaveAuthorizedHistory_Error = ""; if (ViewData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString())) { ClientSessionInfo entity_ClientSessionInfo = null; if (ViewData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString())) { entity_ClientSessionInfo = (ClientSessionInfo)ViewData[Bootstrapper.UserClientSessionKey.ToString()]; } if (entity_ClientSessionInfo != null) { BaseSession entity_BaseSession = entity_SessionWUserInfo; if (entity_BaseSession != null) { WebCommonHelper webCommonHelper = new WebCommonHelper(); webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) => { WCFReturnResult entity = loginUserMgtHelper.Value.Logout(entity_WCFAuthInfoVM); if (!entity.IsSuccess) { str_SaveAuthorizedHistory_Error = string.Join("<br/>", entity.StrList_Error.ToArray()); } else { MVCSessionMgt.RemoveServerSideSession(entity_BaseSession); } }); } if (ViewData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString())) { ViewData.Remove(Bootstrapper.UserClientSessionKey.ToString()); } if (TempData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString())) { TempData.Remove(Bootstrapper.UserClientSessionKey.ToString()); } } } if (!string.IsNullOrWhiteSpace(str_SaveAuthorizedHistory_Error)) { MsgInfo errorMsgInfo = new MsgInfo(); errorMsgInfo.MsgTitle = str_MsgBoxTitle; errorMsgInfo.MsgDesc = str_SaveAuthorizedHistory_Error; errorMsgInfo.MsgType = MessageType.ValidationError; ViewBag.ActionMessage = errorMsgInfo; TempData[ActionMessageKey] = errorMsgInfo; } else { MsgInfo errorMsgInfo = new MsgInfo(); errorMsgInfo.MsgTitle = str_MsgBoxTitle; errorMsgInfo.MsgDesc = strError; errorMsgInfo.MsgType = MessageType.Success; ViewBag.ActionMessage = errorMsgInfo; TempData[ActionMessageKey] = errorMsgInfo; } return(View("Index")); }
public ActionResult Index(LoginUserVM loginUserVM) { //Message Box Title -- When Error occured, Message Box would be showed. string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource("LoginScreentTitle"); ClearSelectionCriteriaFromViewData(); #region [ Add data into language combo box ] if (TempData.Keys.Contains(StaticContent.LanguageKey)) { LanguageKey temp = (LanguageKey)(TempData[StaticContent.LanguageKey]); initLanguageComboBox(temp.ToString()); } else { initLanguageComboBox(); } #endregion LUSerLoginResult entity_LUSerLoginResult = new LUSerLoginResult(); //Define and Create channel factory in order to call the service entity_LUSerLoginResult = loginUserMgtHelper.Value.Login(loginUserVM, TempData[StaticContent.LanguageKey].ToString(), UserHostAddress, UserHostName); if (entity_LUSerLoginResult != null && entity_LUSerLoginResult.StrList_Error.Count == 0) { //Clear the cache. TempData[ActionMessageKey] = ViewBag.ActionMessage = null; //Save login user's authorized info to the cache. MVCSessionMgt.SaveServerSideSession(entity_LUSerLoginResult.Entity_SessionWUserInfo, StaticContent.SystemInfoInst.GetSessionTimeOutSeconds()); //Save service authorized key and client side session key. ClientSessionInfo entity_ClientSessionInfo = new ClientSessionInfo(); if (entity_LUSerLoginResult.Entity_SessionWUserInfo != null) { entity_ClientSessionInfo.MVCSessionKey = entity_LUSerLoginResult.Entity_SessionWUserInfo.SessionKey; entity_ClientSessionInfo.ServiceAuthorizedKey = entity_LUSerLoginResult.Str_ServerToken; Entity_ClientSessionInfo = entity_ClientSessionInfo; TempData[Bootstrapper.UserClientSessionKey.ToString()] = ViewData[Bootstrapper.UserClientSessionKey.ToString()] = entity_ClientSessionInfo; } //Check the password is expire or not. if (entity_LUSerLoginResult.IsPWDExpire) { return(Redirect("/AccessControl/Login/Reset")); } else { return(Redirect("/Home/Index")); } } //Output error. MsgInfo errorMsgInfo = new MsgInfo(); errorMsgInfo.MsgTitle = str_MsgBoxTitle; //Retrieve all error message. errorMsgInfo.MsgDesc = string.Join("<br/>", entity_LUSerLoginResult.StrList_Error.ToArray()); errorMsgInfo.MsgType = MessageType.ValidationError; ViewBag.ActionMessage = errorMsgInfo; TempData[ActionMessageKey] = errorMsgInfo; return(View(loginUserVM)); }