コード例 #1
0
        public ActionResult login(ExecutiveMaster user)
        {
            //sign in new customer
            //Commented and added by sanjeet singh 27th May 2016
            //  user.executiveName = "*****@*****.**";
            //ACS.Core.Domain.Master.ExecutiveMaster _user = null;
            var _user = _userService.GetUserDetailByUserName(user.Emailid);

            _userAuthenticationService.SignIn(_user, false);
            //

            var _FileUpload = _userService.GetFileUploadURL();

            Session["FileUploadPath"] = _FileUpload.keyValue;



            Session["UserName"]       = _workContext.CurrentUser.executiveName;
            Session["UserDepartment"] = _workContext.CurrentUser.DepartmentM.DepartmentName;
            Session["DepartmentId"]   = _workContext.CurrentUser.DepartmentM.Id;
            Session["UserId"]         = _workContext.CurrentUser.Id;
            Session["SessionId"]      = Session.SessionID;
            Session["deptCode"]       = _workContext.CurrentUser.DepartmentM.DepartmentCode;

            Session["UserEmailId"] = _workContext.CurrentUser.Emailid;

            //Added by Prakash on 16/09/2016
            #region Print Permissions
            var    _objPrintPermissions = _userService.GetPrintPermissions();
            string printValue           = null;
            if (!string.IsNullOrEmpty(_objPrintPermissions.keyValue))
            {
                var keyValue = _objPrintPermissions.keyValue.Split(',');
                //foreach (var items in keyValue)
                //{
                //    if (Session["deptCode"].ToString() == items)
                //        printValue = items;
                //    else
                //        printValue = null;
                //}
                string value = Session["deptCode"].ToString();
                int    pos   = Array.IndexOf(keyValue, value);
                if (pos > -1)
                {
                    printValue = value;
                }
                else
                {
                    printValue = null;
                }
            }
            else
            {
                printValue = null;
            }
            Session["PrintPermissions"] = printValue;
            #endregion

            //Added by Ankush on 13/10/2016
            #region GenerateExcel Permissions
            var    _objGenerateExcelPermissions = _userService.GetGenerateExcelPermissions();
            string GenerateExcelValue           = null;
            if (!string.IsNullOrEmpty(_objGenerateExcelPermissions.keyValue))
            {
                var    keyValue = _objGenerateExcelPermissions.keyValue.Split(',');
                string value    = Session["deptCode"].ToString();
                int    pos      = Array.IndexOf(keyValue, value);
                if (pos > -1)
                {
                    GenerateExcelValue = value;
                }
                else
                {
                    GenerateExcelValue = null;
                }
            }
            else
            {
                GenerateExcelValue = null;
            }
            Session["GenerateExcelPermissions"] = GenerateExcelValue;
            #endregion

            //if (Request.QueryString["ReturnUrl"] != null && Request.QueryString["ReturnUrl"].ToString() != "")
            //{
            //    Response.Redirect("~/" + Request.QueryString["ReturnUrl"].ToString());
            //    return null;
            //}
            //else
            //    return RedirectToAction("../Staff/Staff/index");

            //Added by Prakash on 20 March, 2018
            #region
            if (!string.IsNullOrEmpty(_workContext.CurrentUser.Emailid))
            {
                //--manage Login History
                ExecutiveLoginHistory exeHistory = new ACS.Core.Domain.Master.ExecutiveLoginHistory();
                exeHistory.ExecutiveUserName = _workContext.CurrentUser.Emailid;
                exeHistory.LoginTime         = DateTime.Now;
                exeHistory.EnteredBy         = _workContext.CurrentUser.Id;
                _execcutiveService.InsertExecutiveLoginHistory(exeHistory);

                //--get Executive Login History List
                IList <ExecutiveLoginHistory> exeHistoryList = _execcutiveService.GetExecutiveHistoryList(_workContext.CurrentUser.Emailid);
                if (exeHistoryList.Count > 1)
                {
                    exeHistoryList = exeHistoryList.OrderByDescending(i => i.Id).Take(2).ToList();
                    var obj_loginTime = exeHistoryList.OrderBy(i => i.Id).FirstOrDefault().LoginTime;
                    Session["LastLoginDetails"] = obj_loginTime;
                }
                else
                {
                    Session["LastLoginDetails"] = "First Time";
                }
            }
            #endregion

            // return RedirectToAction("../Home/Home/Index");

            if (_user.PwdChanged == "N")
            {
                //return RedirectToAction("../Login/ChangePassword");


                return(RedirectToAction("../Home/Dashboard/Dashboard"));
            }
            else
            {
                return(RedirectToAction("../Home/Dashboard/Dashboard"));
            }

            //
        }