Пример #1
0
        public static void InsertLoginLogoutHistory(LoginLogout _loginLogout, string Ref1)
        {
            MySqlParameter[] param = new MySqlParameter[5];
            param[0] = new MySqlParameter("p_UserID", _loginLogout.UserID);
            param[1] = new MySqlParameter("p_CompID", _loginLogout.CompID);
            param[2] = new MySqlParameter("p_Type", _loginLogout.Type);
            param[3] = new MySqlParameter("p_IPAddress", _loginLogout.IP_Address);
            param[4] = new MySqlParameter("p_Ref1", _loginLogout.Ref1);

            MySqlCommand cmd = new MySqlCommand();

            cmd.Parameters.AddRange(param);
            DataTable dt = DBConnection.GetDataTable("spLoginLogoutHistory", cmd, "");

            /*
             * ResponseBase objResponse = null;
             * DataTable dt = DBConnection.GetDataTable("spLoginLogoutHistory", cmd, "");
             * if (dt.Rows.Count > 0)
             * {
             *  objResponse = new ResponseBase();
             *  objResponse.ReturnCode = dt.Rows[0]["ReturnCode"].ToString();
             *  objResponse.ReturnMessage = dt.Rows[0]["ReturnMessage"].ToString();
             * }
             * else
             * {
             *  objResponse = new ResponseBase();
             *  objResponse.ReturnCode = ConstantMessages.WebServiceLog.GenericErrorCode;
             *  objResponse.ReturnMessage = ConstantMessages.WebServiceLog.GenericErrorMsg;
             * }
             * return objResponse;
             */
        }
Пример #2
0
        public ActionResult Index()
        {
            LoginLogout ll = new LoginLogout();

            connection();
            try
            {
                con.Open();
                using (SqlCommand cmd1 = new SqlCommand("SELECT account_id,account_type FROM Account_Details", con))
                {
                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter(cmd1);
                    da.Fill(ds);
                    List <LoginLogout> account = new List <LoginLogout>();
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        LoginLogout uobj = new LoginLogout();
                        uobj.AccountID   = Convert.ToInt32(ds.Tables[0].Rows[i]["account_id"].ToString());
                        uobj.AccountType = ds.Tables[0].Rows[i]["account_type"].ToString();
                        account.Add(uobj);
                    }
                    ll.AccountList = account;
                }
                con.Close();
                return(View(ll));
            }
            catch (SqlException)
            {
                ViewData["message"] = "Login Attempt Failed! Check Email And Password";
            }

            return(View());
        }
Пример #3
0
        public void LHLogin()
        {
            // var test = extent.CreateTest("<div style='color:green; font -weight : bold'>Create Admin</div>", "This case may attains passed or failed");
            try
            {
                string paths = @"C:\ExcelReports\LoginLogout.xlsx";
                ExcelLogin.PopulateInCollection(paths);

                LH = new ChromeDriver();
                LH.Manage().Window.Maximize();
                LH.Manage().Cookies.DeleteAllCookies();
                LH.Navigate().GoToUrl("https://app-latest-us4.usdev.wfsaas.net/#/login");

                // Assert.AreEqual("latest", LH.Title);


                WebDriverWait wait = new WebDriverWait(LH, TimeSpan.FromSeconds(15));
                // test.Log(Status.Info, "Steps are Processing");
                // test.Log(Status.Info, "Create Admin steps are processing");

                LoginLogout login = new LoginLogout(LH);
                //PageFactory.InitElements(Atlas, login);
                login.AccountId1();
                login.CliNext1();
                login.UserName1();
                login.Password1();
                login.assetforgot();



                login.submit1();
                login.usernav1();
                login.logout1();

                // System.Threading.Thread.Sleep(20000);
                //// string screenshot = Util.Capture(Atlas, "Create Admin");
                //test.Pass("Create Admin been completed");
                //test.Pass("Create Admin been Done");
                //// test.AddScreenCaptureFromPath(screenshot);
            }
            catch (Exception e)
            {
                //test.Log(Status.Fail, "So SAD");
                // string screenshots3 = Util.Capture(Atlas, "Failed Admin");
                //test.Fail("Admin Case been failed :(");

                //  test.AddScreenCaptureFromPath(screenshots3);

                Console.WriteLine(e.Message);
            }
            finally
            {
                extent.Flush();
            }
        }
Пример #4
0
        public void AuditarLogOut(Usuario oUsuario)
        {
            LoginLogout oLogOut = new LoginLogout();

            oLogOut.Usuario    = oUsuario.IDusuario;
            oLogOut.FechayHora = DateTime.Now;
            oLogOut.Operacion  = "LogOut";

            Modelo.Auditoria.ObtenerInstancia().AddToLogInsOuts(oLogOut);
            Modelo.Auditoria.ObtenerInstancia().SaveChanges();
        }
Пример #5
0
 public ActionResult Welcome(LoginLogout ll)
 {
     if (Session["UserId"] != null && Session["Accountid"] != null)
     {
         ViewData["email"] = ll.Email;
         return(View("Welcome", "AfterLoginView"));
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Пример #6
0
        public void Executar(int usuarioId, string maquina)
        {
            var usuario = this.usuarioRepositorio.ObterPorId(usuarioId);

            this.loginLogoutRepositorio.GravarLogoutDosPendentes(usuario.Id, usuario.UltimoAcesso.GetValueOrDefault());

            var loginLogout = new LoginLogout
            {
                Usuario   = usuario,
                DataLogin = DateTime.Now,
                Maquina   = maquina
            };

            this.loginLogoutRepositorio.Salvar(loginLogout);
        }
 public ActionResult Index()
 {
     connection();
     try
     {
         LoginRepo   Lr = new LoginRepo();
         LoginLogout ll = Lr.dropdownrepo();
         return(View(ll));
     }
     catch (SqlException)
     {
         ViewData["message"] = "Login Attempt Failed! Check Email And Password";
     }
     return(View());
 }
Пример #8
0
        public ActionResult Index(LoginLogout ll, FormCollection form) //this is the login page which u will see at first.
        {
            connection();
            try
            {
                string accountid = Convert.ToString(form["AccountList"]);
                con.Open();
                using (SqlCommand cmd = new SqlCommand("SP_Login_Logout", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@email", ll.Email);
                    cmd.Parameters.AddWithValue("@password", ll.Password);
                    cmd.Parameters.AddWithValue("@accountid", accountid);    //create  A drop down in the login page stating account type and while clicking login dropdown should send the account number .
                    cmd.ExecuteNonQuery();
                    SqlDataReader sqd = cmd.ExecuteReader();
                    if (sqd.Read())
                    {
                        FormsAuthentication.SetAuthCookie(ll.Email, true);
                        Session["UserId"]    = sqd["userid"];
                        Session["Accountid"] = sqd["account_id"];

                        return(RedirectToAction("Welcome", ll));
                    }
                    else
                    {
                        ViewData["message"] = "Login Attempt Failed! Check Email And Password";
                    }
                }

                con.Close();
            }
            catch (SqlException)
            {
                ViewData["message"] = "Login Attempt Failed! Check Email And Password";
            }
            catch (NullReferenceException)
            {
                ViewData["message"] = "Login Attempt Failed! Check Email And Password";
            }

            ViewBag.DuplicateMesaage = "Wrong Credentials";
            return(RedirectToAction("Index"));
        }
Пример #9
0
 public void UserLogin(string username, string password)
 {
     try
     {
         if (LoginLogout.UserLogin(username, password))
         {
             LoggedInBrowseWindow loggedInBrowseWindow = new LoggedInBrowseWindow();
             loggedInBrowseWindow.Show();
         }
     }
     catch (UserNotFoundException)
     {
         MessageBox.Show("Ilyen felhasználó nem létezik!");
     }
     catch (IncorrectPasswordException)
     {
         MessageBox.Show("Helytelen jelszó!");
     }
 }
Пример #10
0
 public void UserLogin(string username, string password)
 {
     try
     {
         if (LoginLogout.UserLogin(username, password))
         {
             new MainContainerWindow().Show();
             Application.Current.MainWindow.Close();
         }
     }
     catch (UserNotFoundException)
     {
         MessageBox.Show("Ilyen felhasználó nem létezik!");
     }
     catch (NotCorrectPasswordException)
     {
         MessageBox.Show("Helytelen jelszó!");
     }
 }
Пример #11
0
 public void UserLogin(string username, string password)
 {
     try
     {
         if (LoginLogout.UserLogin(username, password))
         {
             new TimeTableWindow().Show();
             Application.Current.MainWindow.Close();
         }
     }
     catch (UserNotFoundException ex)
     {
         ExceptionLogger.LogException(ex);
         MessageBox.Show("Username does not exist!");
     }
     catch (NotCorrectPasswordException ex)
     {
         ExceptionLogger.LogException(ex);
         MessageBox.Show("Incorrect password!");
     }
 }
 public LoginLogout dropdownrepo()
 {
     ll = new LoginLogout();
     connection();
     con.Open();
     using (SqlCommand cmd1 = new SqlCommand("SELECT account_id,account_type FROM Account_Details", con))
     {
         DataSet        ds = new DataSet();
         SqlDataAdapter da = new SqlDataAdapter(cmd1);
         da.Fill(ds);
         List <LoginLogout> account = new List <LoginLogout>();
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             LoginLogout uobj = new LoginLogout();
             uobj.AccountID   = Convert.ToInt32(ds.Tables[0].Rows[i]["account_id"].ToString());
             uobj.AccountType = ds.Tables[0].Rows[i]["account_type"].ToString();
             account.Add(uobj);
         }
         ll.AccountList = account;
     }
     con.Close();
     return(ll);
 }
Пример #13
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                lblError.Text = "";
                if (string.IsNullOrEmpty(txtUserEmail.Text.Trim()) || string.IsNullOrEmpty(txtUserPassword.Text.Trim()))
                {
                    //lblError.Text = ConstantMessages.Login.InvalidUser;
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "Swal.fire({text: '" + ConstantMessages.Login.InvalidUser + "',allowOutsideClick:false})", true);
                    return;
                }
                else
                {
                    LoginRequest objRequest = new LoginRequest();
                    objRequest.UserName = txtUserEmail.Text.Trim();
                    objRequest.Password = txtUserPassword.Text;

                    UserBO objResponse = new UserBO();
                    objResponse = UserDAL.LoginUser(objRequest);

                    if (objResponse.ReturnCode == "1")
                    {
                        //Login Log
                        LoginLogout _loginLogout = new LoginLogout();
                        _loginLogout.UserID     = objResponse.UserID;
                        _loginLogout.CompID     = objResponse.CompId.ToString();
                        _loginLogout.Type       = "login";
                        _loginLogout.IP_Address = Utility.GetClientIPaddress();
                        UserDAL.InsertLoginLogoutHistory(_loginLogout, "");
                        //End Login Log

                        GetAccessToken(txtUserEmail.Text.Trim(), txtUserPassword.Text.Trim());

                        if (HttpContext.Current.Session["access_token"] == null)
                        {
                            //lblError.Text = ConstantMessages.WebServiceLog.GenericErrorMsg;
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "Swal.fire({text: '" + ConstantMessages.WebServiceLog.GenericErrorMsg + "',allowOutsideClick:false})", true);

                            return;
                        }
                        else
                        {
                            // Call Login Business Layer Function to record message
                            Utility.CreateUserSession(objResponse.UserID, objResponse.Role, objResponse.FirstName, objResponse.LastName, objResponse.CompId);

                            //For ProfilePic,CompanyProfilePic & Theme
                            var UserDetails = UserDAL.GetUserDetailsByUserID(objResponse.UserID, "");
                            if (UserDetails != null && !string.IsNullOrEmpty(UserDetails.ProfilePicFileID))
                            {
                                //HttpContext.Current.Session["ProfilePicFile"] = Utility.GetBase64ImageByFileID(UserDetails.ProfilePicFileID, "~/Files/ProfilePic/");
                                //HttpContext.Current.Session["CompanyProfilePicFile"] = Utility.GetBase64ImageByFileID(UserDetails.CompanyProfilePicFileID, "~/Files/CompLogo/");
                                //HttpContext.Current.Session["ThemeColor"] = UserDetails.ThemeColor;

                                HttpContext.Current.Session["ThemeColor"]  = UserDetails.ThemeColor;
                                HttpContext.Current.Session["ThemeColor2"] = UserDetails.ThemeColor2;
                                HttpContext.Current.Session["ThemeColor3"] = UserDetails.ThemeColor3;
                                HttpContext.Current.Session["ThemeColor4"] = UserDetails.ThemeColor4;
                                HttpContext.Current.Session["Favicon"]     = UserDetails.FaviconFileID;

                                Utility.CreateProfileAndThemeSession(UserDetails.ProfilePicFileID, UserDetails.CompanyProfilePicFileID, UserDetails.ThemeColor);
                            }
                            //End For ProfilePic,CompanyProfilePic & Theme

                            if (objResponse.IsFirstLogin == "1" || objResponse.IsFirstPasswordNotChanged == "1")
                            {
                                if (objResponse.IsFirstLogin == "1")
                                {
                                    Utility.CreateFirstLoginSession(true);
                                    //HttpContext.Current.Session["IsFirstLogin"] = true;
                                }
                                if (objResponse.IsFirstPasswordNotChanged == "1")
                                {
                                    Utility.CreateFirstPasswordNotChangedSession(true);
                                    //HttpContext.Current.Session["IsFirstPasswordNotChanged"] = true;
                                }
                                if (objResponse.IsFirstLogin == "1")
                                {
                                    Response.Redirect("~/t/Settings.aspx", false);
                                }
                                else if (objResponse.IsFirstPasswordNotChanged == "1")
                                {
                                    Response.Redirect("~/t/ChangePassword.aspx", false);
                                }
                            }
                            else
                            {
                                Utility.CreateFirstLoginSession(false);
                                if (objResponse.Role.ToLower() == "enduser")
                                {
                                    Response.Redirect("~/t/default.aspx", false);
                                }
                                else if (objResponse.Role.ToLower() == "superadmin" || objResponse.Role.ToLower() == "companyadmin" || objResponse.Role.ToLower() == "subadmin")
                                {
                                    Response.Redirect("~/t/dashboard.aspx", false);
                                }
                            }
                        }
                    }
                    else
                    {
                        // Call Login Business Layer Function to record message
                        //lblError.Text = objResponse.ReturnMessage;
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "Swal.fire({text: '" + objResponse.ReturnMessage + "',allowOutsideClick:false})", true);
                    }
                }
            }
            catch (Exception ex)
            {
                //lblError.Text = ConstantMessages.WebServiceLog.GenericErrorMsg;
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "Swal.fire({text: '" + ConstantMessages.WebServiceLog.GenericErrorMsg + "',allowOutsideClick:false})", true);
            }
        }
Пример #14
0
        protected void ProceedToSuccessLoginProcess(UserBO objResponse, string UserName, string Password)
        {
            //HttpCookie myOldCookie = Request.Cookies["UserInfo"];
            //if (myOldCookie == null)
            //{
            //    HttpCookie myCookie = new HttpCookie("UserInfo");
            //    myCookie.Values.Add("userid", objResponse.UserID);
            //    myCookie.Expires = DateTime.Now.AddMonths(1);
            //    Response.Cookies.Add(myCookie);
            //}

            Response.Cookies["userid"].Value   = objResponse.UserID;
            Response.Cookies["userid"].Expires = DateTime.Now.AddMonths(1);


            //HttpCookie _userInfoCookies = new HttpCookie("UserInfo");
            //_userInfoCookies["UserId"] = objResponse.UserID;
            //_userInfoCookies.Expires = DateTime.Now.AddMonths(1);
            //Response.Cookies.Add(_userInfoCookies);
            //End

            //Login Log
            LoginLogout _loginLogout = new LoginLogout();

            _loginLogout.UserID     = objResponse.UserID;
            _loginLogout.CompID     = objResponse.CompId.ToString();
            _loginLogout.Type       = "login";
            _loginLogout.IP_Address = Utility.GetClientIPaddress();
            UserDAL.InsertLoginLogoutHistory(_loginLogout, "");
            //End Login Log

            GetAccessToken(UserName, Password);

            if (HttpContext.Current.Session["access_token"] == null)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "Swal.fire({text: '" + ConstantMessages.WebServiceLog.GenericErrorMsg + "',allowOutsideClick:false})", true);
                return;
            }
            else
            {
                // Call Login Business Layer Function to record message
                Utility.CreateUserSession(objResponse.UserID, objResponse.Role, objResponse.FirstName, objResponse.LastName, objResponse.CompId, objResponse.EmailID, objResponse.OrganizationName);

                List <ActiveUser> lstActiveUsers = new List <ActiveUser>();
                if (Cache["ActiveUsers"] != null)
                {
                    lstActiveUsers = (List <ActiveUser>)Cache["ActiveUsers"];
                }
                ActiveUsersCache cache = new ActiveUsersCache();
                cache.AddOrUpdate(lstActiveUsers, objResponse.UserID, objResponse.EmailID, objResponse.FirstName + " " + objResponse.LastName, Session.SessionID);
                Cache["ActiveUsers"] = lstActiveUsers;

                //For ProfilePic,CompanyProfilePic & Theme
                var UserDetails = UserDAL.GetUserDetailsByUserID(objResponse.UserID, "");
                if (UserDetails != null && !string.IsNullOrEmpty(UserDetails.ProfilePicFileID))
                {
                    HttpContext.Current.Session["ThemeColor"]  = UserDetails.ThemeColor;
                    HttpContext.Current.Session["ThemeColor2"] = UserDetails.ThemeColor2;
                    HttpContext.Current.Session["ThemeColor3"] = UserDetails.ThemeColor3;
                    HttpContext.Current.Session["ThemeColor4"] = UserDetails.ThemeColor4;
                    HttpContext.Current.Session["Favicon"]     = UserDetails.FaviconFileID;

                    Utility.CreateProfileAndThemeSession(UserDetails.ProfilePicFileID, UserDetails.CompanyProfilePicFileID, UserDetails.ThemeColor);
                }
                //End For ProfilePic,CompanyProfilePic & Theme

                if (objResponse.IsFirstLogin == "1" || objResponse.IsFirstPasswordNotChanged == "1")
                {
                    if (objResponse.IsFirstLogin == "1")
                    {
                        Utility.CreateFirstLoginSession(true);
                    }
                    if (objResponse.IsFirstPasswordNotChanged == "1")
                    {
                        Utility.CreateFirstPasswordNotChangedSession(true);
                    }
                    if (objResponse.IsFirstLogin == "1")
                    {
                        Response.Redirect("~/t/Settings.aspx", false);
                    }
                    else if (objResponse.IsFirstPasswordNotChanged == "1")
                    {
                        Response.Redirect("~/t/ChangePassword.aspx", false);
                    }
                }
                else
                {
                    Utility.CreateFirstLoginSession(false);

                    //Added on 04 Jun 20 to preview add course without login
                    if (Request.QueryString["url"] != null && !string.IsNullOrEmpty(Convert.ToString(Request.QueryString["url"])))
                    {
                        string requestedurl = Convert.ToString(Request.QueryString["url"]);
                        requestedurl = HttpUtility.UrlDecode(requestedurl);
                        Response.Redirect(requestedurl);
                    }

                    //if (HttpContext.Current.Session["requestedurlcourse"] != null)
                    //{
                    //    string requestedurl = Convert.ToString(HttpContext.Current.Session["requestedurlcourse"]);
                    //    HttpContext.Current.Session["requestedurlcourse"] = null;
                    //    Response.Redirect(requestedurl);
                    //}
                    //End

                    //This is used to redirect user on specific page where he requested .Purpose of this is to navigate already logged in user in same browser
                    HttpCookie myCookie = Request.Cookies["UserInfo"];
                    if (myCookie != null && HttpContext.Current.Session["requestedurl"] != null)
                    {
                        string requestedurl = Convert.ToString(HttpContext.Current.Session["requestedurl"]);
                        HttpContext.Current.Session["requestedurl"] = null;
                        Response.Redirect(requestedurl);
                    }
                    //End

                    if (objResponse.Role.ToLower() == "enduser")
                    {
                        Response.Redirect("~/t/default.aspx", false);
                    }
                    else if (objResponse.Role.ToLower() == "superadmin" || objResponse.Role.ToLower() == "companyadmin" || objResponse.Role.ToLower() == "subadmin")
                    {
                        Response.Redirect("~/t/dashboard.aspx", false);
                    }
                }
            }
        }
 public void UserLogout()
 {
     LoginLogout.UserLogout();
     new LoginRegContainer().Show();
     Application.Current.Windows[0].Close();
 }
        public ActionResult Index(LoginLogout ll, FormCollection form) //this is the login page which u will see at first.
        {
            //Twilio
            //const string accountSid = "";
            //const string authToken = "";

            //TwilioClient.Init(accountSid, authToken);

            connection();
            try
            {
                //string accountid = Convert.ToString(form["AccountList"]);
                con.Open();
                using (SqlCommand cmd = new SqlCommand("SP_Login_Logout", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@email", ll.Email);
                    cmd.Parameters.AddWithValue("@password", ll.Password);
                    //cmd.Parameters.AddWithValue("@accountid", accountid);//create  A drop down in the login page stating account type and while clicking login dropdown should send the account number .
                    cmd.ExecuteNonQuery();
                    SqlDataReader sqd = cmd.ExecuteReader();
                    if (sqd.Read())
                    {
                        FormsAuthentication.SetAuthCookie(ll.Email, true);
                        Session["UserId"]          = sqd["userid"];
                        Session["Accountid"]       = sqd["account_id"];
                        Session["Name"]            = sqd["name"];
                        Session["Wallet"]          = sqd["wallet"];
                        Session["PhoneNo"]         = sqd["contact"];
                        Session["AdminCount"]      = sqd["admin_count"];
                        Session["InstructorCount"] = sqd["instructor_count"];
                        Session["UserCount"]       = sqd["user_count"];
                        Session["CategoryCount"]   = sqd["category_count"];
                        Session["CourseCount"]     = sqd["course_count"];

                        //var message = MessageResource.Create(
                        //body: "You have Logged in to Learning App Please remember UserID For Future Needs: " + Convert.ToInt32(Session["UserId"]) + " And Your Current Wallet Amount is:" + Convert.ToInt32(Session["Wallet"]) + "",
                        //from: new Twilio.Types.PhoneNumber("+12057758497"),
                        //to: new Twilio.Types.PhoneNumber("+91" + Session["PhoneNo"].ToString())
                        //);
                        return(RedirectToAction("Welcome", ll));
                    }
                    else
                    {
                        ViewData["error"] = "Invalid Credentials! Please enter the details properly and try again.";
                    }
                }
                con.Close();
                return(View(ll));
            }
            catch (SqlException)
            {
                ViewData["error"] = "Invalid Credentials! Please enter the details properly and try again.";
                return(View(ll));
            }
            catch (NullReferenceException)
            {
                ViewData["error"] = "Invalid Credentials! Please enter the details properly and try again.";
                return(View(ll));
            }
        }