示例#1
0
        /// <summary>
        /// Submit Login History
        /// </summary>
        /// <param name="dailyLoginHistory"></param>
        /// <returns></returns>
        public bool SubmitDailyLoginHistory(DailyLoginHistoryBO dailyLoginHistory)
        {
            DailyLoginHistory LoginHistory = new DailyLoginHistory();

            ObjectMapper.Map(dailyLoginHistory, LoginHistory);
            return(UserRepository.SubmitDailyLoginHistory(LoginHistory));
        }
示例#2
0
        /// <summary>
        /// Submit Login History
        /// </summary>
        /// <param name="dailyLoginHistory"></param>
        /// <returns></returns>
        public DailyLoginHistoryBO GetActiveLogin(int empID, int LoginType)
        {
            DailyLoginHistoryBO dailyLoginHistory = new DailyLoginHistoryBO();

            ObjectMapper.Map(UserRepository.GetActiveLogin(empID, LoginType), dailyLoginHistory);
            return(dailyLoginHistory);
        }
示例#3
0
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            try
            {
                ExceptionEngine.AppExceptionManager.Process(() =>
                {
                    if (!String.IsNullOrEmpty(model.UserName.Trim()) && !String.IsNullOrEmpty(model.Password.Trim()))
                    {
                        ActivityLog.SetLog("Initializing LogIn Page for user : "******"Login Response >> " + loginResponse.ToString() + " <<", LogLoc.DEBUG);
                        if (loginResponse > 0)
                        {
                            List <string> ErrorMessage = new List <string>();

                            #region Show popup if sessionID not matching with existing SessionID
                            HttpContext.Session[PageConstants.SESSION_USER_ID] = loginResponse;

                            var dailyLoginHistory = UserBusinessInstance.GetActiveLogin(loginResponse, (int)AspectEnums.AnnouncementDevice.Console);

                            if (dailyLoginHistory.SessionID != null)
                            {
                                if (HttpContext.Session.SessionID != dailyLoginHistory.SessionID)
                                {
                                    ActivityLog.SetLog("Multiple session found user : "******"Login Success! Going to call WelcomeUserAccuITAdmin: ", LogLoc.DEBUG);
                                    WelcomeUserAccuITAdmin(loginResponse); //Permit user to access application
                                    return;
                                }
                            }
                            else
                            {
                                ActivityLog.SetLog("No existing sessionID found. Creating new session: ", LogLoc.DEBUG);
                                DailyLoginHistoryBO LoginHistory = new DailyLoginHistoryBO()
                                {
                                    UserID      = loginResponse,
                                    LoginTime   = System.DateTime.Now,
                                    SessionID   = Session.SessionID,
                                    IpAddress   = Request.ServerVariables["REMOTE_ADDR"],
                                    IsLogin     = true,
                                    BrowserName = Request.Browser.Browser.ToString(),
                                    LoginType   = (int)AspectEnums.AnnouncementDevice.Console,
                                };
                                UserBusinessInstance.SubmitDailyLoginHistory(LoginHistory);
                                WelcomeUserAccuITAdmin(loginResponse);
                                return;
                            }

                            #endregion
                        }
                    }
                }, AspectEnums.ExceptionPolicyName.AssistingAdministrators.ToString());
            }
            catch (Exception ex)
            {
                ActivityLog.SetLog("Exception : Message| " + ex.Message, LogLoc.ERROR);
                ViewBag.IsSuccess = false;
                ViewBag.ShowPopup = true;
                ViewBag.Message   = "Connection to server failed. Please try again.";
                return(View());
            }

            if (loginResponse == (int)AspectEnums.LoginAccessType.Terminate)
            {
                ViewBag.Message = Messages.TerminateSessionConfirmation;
            }
            else if (loginResponse == (int)AspectEnums.UserLoginAttemptStatus.WrongPassword)
            {
                ViewBag.Message = Messages.LoginWrongPassword + " : Incorrect Password!";
            }
            else if (loginResponse == (int)AspectEnums.UserLoginAttemptStatus.WrongUserId)
            {
                ViewBag.Message = Messages.LoginWrongUserId + " : Incorrect UserName!";
            }
            else if (loginResponse == (int)AspectEnums.UserLoginAttemptStatus.InActive)
            {
                ViewBag.Message = Messages.LoginInActive;
            }
            else if (loginResponse == (int)AspectEnums.UserLoginAttemptStatus.Locked)
            {
                ViewBag.Message = Messages.LoginLocked;
            }
            else if (loginResponse == (int)AspectEnums.UserLoginAttemptStatus.InvalidWebUser)
            {
                ViewBag.Message = "You are not authorized to login, please contact your administrator";
                Response.Redirect("~/Account/UnAuthorizedUser", true);
                return(View("UnAuthorizedUser", "Account"));
            }
            else if (loginResponse > (int)AspectEnums.UserLoginAttemptStatus.Successful)
            {
                ViewBag.ShowPopup = false;
                if (USERPROFILE.IsAdmin)
                {
                    return(RedirectToAction("Index", "Admin"));
                }
                return(RedirectToAction("Index", "Home"));
            }

            if (loginResponse < 0)
            {
                ViewBag.IsSuccess = false; ViewBag.ShowPopup = true;
            }

            return(View());
        }