public static Tbl_User_Detail SaveUser(Tbl_User_Detail obj)
        {
            Tbl_User_Detail tbl = new Tbl_User_Detail();

            using (CBDB db = new CBDB())
            {
                tbl = db.Tbl_User_Detail.Where(x => x.UserName.Equals(obj.UserName)).FirstOrDefault();
                if (tbl == null)
                {
                    if (obj.Usergroup.ToLower().Contains("admin"))
                    {
                        obj.GroupPages = "CaseStat ,WCStat ,SLA ,CaseHistory ,CaseClosure ,MtchedTran ,UnmtchedTran ,Recon,RobotConfig";
                    }
                    else
                    {
                        obj.GroupPages = "CaseStat ,WCStat ,SLA ,CaseHistory ,CaseClosure ,MtchedTran ,UnmtchedTran ,Recon";
                    }
                    db.Tbl_User_Detail.Add(obj);
                    db.SaveChanges();
                    tbl = obj;
                }
            }
            return(tbl);
        }
Exemple #2
0
        public ActionResult LogIn(string uname, string pwd)
        {
            if (string.IsNullOrEmpty(pwd))
            {
                return(RedirectToAction("LogIn", "LogIn"));
            }

            pwd = pwd.Trim();
            bool   logincheck = false;
            string key        = Session["LoginKey"].ToString();

            pwd = MvcHelper.DecryptToBytesUsingCBC(Convert.FromBase64String(pwd), key);
            pwd = pwd.Trim();
            string          ErrorMsg = string.Empty; string Action = string.Empty; string cntrlr = string.Empty, groupname = string.Empty;
            Tbl_User_Detail user    = new Tbl_User_Detail();
            string          allpage = "CaseStat ,WCStat ,SLA ,CaseHistory ,CaseClosure ,MtchedTran ,UnmtchedTran ,Recon";

            //ADManager AdObj = new ADManager();
            //logincheck = AdObj.ChcekLogin(uname, pwd, ref groupname);


            user = FDHelper.GetUser(uname, pwd);

            if (user != null)
            {
                logincheck = true;
                groupname  = user.Usergroup;
            }

            if (logincheck)
            {
                if (!string.IsNullOrEmpty(groupname))
                {
                    user = new Tbl_User_Detail()
                    {
                        UserName  = uname,
                        Usergroup = groupname,
                    };
                    // user.GroupPages = MvcHelper.GetGroupPages(groupname);
                    bool check = FDHelper.CheckMachine(user.UserName.Trim().ToString());
                    if (check)
                    {
                        Session["USerName"] = user.UserName.Trim().ToString();
                        var table = FDHelper.SaveUser(user);
                        user.GroupPages = string.IsNullOrEmpty(table.GroupPages)?allpage:table.GroupPages;
                        if (user.Usergroup.Equals(Constants.UserGroups.UserManager))
                        {
                            Action = "UserManagement"; cntrlr = "CB";
                        }
                        else
                        {
                            Action = FDHelper.GetPageName(user.GroupPages);
                            cntrlr = "CB";
                        }
                        //WriteToLogFile.writeMessage("Machine is available User will be Redirected to -- Action = index cntrlr = Dashboard");
                    }
                    else
                    {
                        //WriteToLogFile.writeMessage("Sorry...!!! Multiple user login is not allowed.");
                        ErrorMsg = "Sorry...!!! Multiple user login is not allowed.";
                    }
                }
                else
                {
                    //WriteToLogFile.writeMessage("User type is not authorized for the dashboard...!");
                    ErrorMsg = "User type is not authorized for the dashboard...!";
                }
            }
            else
            {
                //WriteToLogFile.writeMessage("Wrong credential...!");
                ErrorMsg = "Wrong credential...!";
            }

            if (!string.IsNullOrEmpty(ErrorMsg))
            {
                //WriteToLogFile.writeMessage("Error msg" +ErrorMsg +"Redirecting to [GET] login page");
                TempData["invalidmsg"] = ErrorMsg;

                return(RedirectToAction("LogIn"));
            }
            else
            {
                Session["User"] = user;
                //WriteToLogFile.writeMessage("[HttpPost]Login  Ended");
                //WriteToLogFile.writeMessage("Redirecting to -- Action = +"+Action.ToString() +" cntrlr = " + cntrlr.ToString());
                return(RedirectToAction(Action, cntrlr));
            }
        }