コード例 #1
0
 public ActionResult Logoff()
 {
     UserOnlineManager.DisConnect();
     Authentication.SignOut();
     ViewBag.IsLoggingOut = true;
     DataSessionManager.RemoveAllData();
     return(RedirectToAction("Checkin", "Account", new { area = "" }));
 }
コード例 #2
0
        public ActionResult Checkin()
        {
            CheckInUser model = new CheckInUser();

            DataSessionManager.RemoveAllData();

            Authentication.SignOut();
            ViewBag.IsLoggingOut = true;
            UserOnlineManager.DisConnect();

            return(View(model));
        }
コード例 #3
0
        public ActionResult Checkin(CheckInUser model)
        {
            DataSessionManager.RemoveAllData();
            if (TryUpdateModel <CheckInUser>(model) && !string.IsNullOrWhiteSpace(model.Username) && !string.IsNullOrWhiteSpace(model.Password))
            {
                model.Username = model.Username.Trim().ToLower();
                bool valid = Authentication.ValidateUser(model.Username, model.Password);

                if (valid)
                {
                    SharedContext.Current.LoggedProfile = EOfficeService.current.Login(model, out ErrorResult);
                    if (SharedContext.Current.LoggedProfile == null)
                    {
                        ViewBag.ErrorMessage = "Thông tin đăng nhập chưa có trên hệ thống OCB OFFICE, anh/chị vui lòng liên hệ với [email protected] để được hỗ trợ";
                    }
                    else
                    {
                        var lst = SystemService.Current.GetHistoryCheckInByUserName(model.Username, out ErrorResult);
                        var checkHaveCheckIn = lst.Any(x => x.DateCheckIn_Parse != null && x.DateCheckIn_Parse.Value.Date == DateTime.Today.Date);
                        if (checkHaveCheckIn == false)
                        {
                            SystemService.Current.Checkin(model.Username, model.NoteCheckIn, out ErrorResult);
                        }
                        ViewBag.ErrorResult = ErrorResult;
                        Authentication.SignOn(model.Username);
                        var returnUrl = Request["ReturnUrl"];
                        if (string.IsNullOrWhiteSpace(returnUrl))
                        {
                            return(Redirect(Utils.GetAppSetting("DefaultPageAfterLogin")));
                        }
                        else
                        {
                            return(Redirect(returnUrl));
                        }
                    }
                }
                else
                {
                    ViewBag.ErrorMessage = "Điểm danh thất bại";
                }
            }
            else
            {
                Authentication.SignOut();
                ViewBag.IsLoggingOut = true;
                UserOnlineManager.DisConnect();
            }

            return(View(model));
        }