コード例 #1
0
 public void PrepareSession(LoginObjectModel lom, Dictionary <string, string> empList, HttpSessionStateBase session)
 {
     session["Role"]           = lom.role;
     session["HeadID"]         = lom.superiorID;
     session["HeadName"]       = lom.superiorName;
     session["EmployeeName"]   = lom.employeeName;
     session["EmployeeID"]     = lom.employeeId;
     session["DepartmentID"]   = lom.departmentId;
     session["DepartmentName"] = lom.departmentName;
     session["Username"]       = lom.userName;
     session["Password"]       = lom.password;
     session["EmployeeList"]   = empList;
     session["MessageBack"]    = "";
 }
コード例 #2
0
        public ActionResult Index(LoginObjectModel model)
        {
            if (ModelState.IsValid)
            {
                EmployeeDTO employeeDTO = new EmployeeDTO();

                employeeDTO.AttemptDate = DateTime.Now;
                employeeDTO.UserName    = model.UserName;
                employeeDTO.Password    = model.Password;

                LoginUsers loginUsers = new LoginUsers();

                employeeDTO = loginUsers.UserLogin(employeeDTO);

                if (employeeDTO != null && employeeDTO.EmpId != 0)
                {
                    var UserRoleCode = Helper.GetLookupCode(employeeDTO.UserRoleLookupId);

                    if (UserRoleCode == Constraints.Admin)
                    {
                        return(RedirectToAction("AdminHome", "Admin", employeeDTO));
                    }
                    else if (UserRoleCode == Constraints.ProjectManager)
                    {
                        return(RedirectToAction("PMHome", "PM", employeeDTO));
                    }
                    else if (UserRoleCode == Constraints.Technician)
                    {
                        return(RedirectToAction("TechHome", "Tech", employeeDTO));
                    }
                    else
                    {
                        return(RedirectToAction("DispatchHome", "Dispatch", employeeDTO));
                    }
                }
                else
                {
                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }
コード例 #3
0
        public LoginObjectModel ValidateUser(LoginObjectModel model)
        {
            string username = model.userName;
            string password = model.password;

            using (WebClient wc = new WebClient())
            {
                var json = wc.DownloadString("http://" + ConstantsConfig.ipaddress + "/LoginServiceIIS.svc/LoginGet?username="******"&password=" + password);
                try
                {
                    model = JsonConvert.DeserializeObject <LoginObjectModel>(json);
                    return(model);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
コード例 #4
0
 public ActionResult Login(LoginObjectModel model)
 {
     if (ModelState.IsValid)
     {
         model = commonBizLogic.ValidateUser(model);
         //Login fail
         if (model is null)
         {
             ViewBag.NotAuthorised = true;
             return(View());
         }
         Dictionary <string, string> empList = commonBizLogic.GetEmployeeList(model.userName, model.password, model.departmentId);
         commonBizLogic.PrepareSession(model, empList, Session);
         //currently testing using requisition history page
         return(RedirectToAction("Welcome", "Home"));
     }
     // Model State failed (basic validation), redisplay form
     return(View(model));
 }