Exemplo n.º 1
0
        public UserProfile GetById(Guid userId)
        {
            bl_User blUser = new bl_User();
            var     model  = new UserProfile(blUser.GetById(userId));

            return(model);
        }
Exemplo n.º 2
0
        public TopModel GetTop(Guid userId, int top = 10)
        {
            bl_User  blUser = new bl_User();
            TopModel model  = new TopModel();

            model.CurrentUser = new UserProfile(blUser.GetById(userId));
            model.UserList    = blUser.GetTop(10)
                                .Select(m => new UserProfile(m))
                                .ToList();

            return(model);
        }
Exemplo n.º 3
0
 public ActionResult Update(M_User objUser)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(Convert.ToString(objUser.Id)))
         {
             var vObj = _blUser.GetById(objUser.Id);
             if (vObj != null)
             {
                 vObj.Phone      = objUser.Phone;
                 vObj.ModifyDate = DateTime.Now;
                 vObj.ModifyBy   = _objAuthentication.UserName;
                 _blUser.Update(vObj);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(Json(objUser));
 }
Exemplo n.º 4
0
        public ActionResult CloseWindows()
        {
            bl_User _objUser = new bl_User();

            DateTime dCurrentLoginTime = DateTime.Now;
            string   sCurrentLoginIP   = string.Empty;

            // ********************************** // ***************************************
            string hostName = Dns.GetHostName();                                     // Retrive the Name of HOST

            sCurrentLoginIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); // Get the

            #region Update Login Detail

            if (!string.IsNullOrWhiteSpace(_objAuthentication.UserName) && !string.IsNullOrWhiteSpace(_objAuthentication.Id))
            {
                Guid guid = new Guid(_objAuthentication.Id);

                var vObj = _objUser.GetById(guid);
                if (vObj != null)
                {
                    vObj.LastLoginTime = DateTime.Now;
                    vObj.LastLoginIP   = sCurrentLoginIP;
                    _objUser.Update(vObj);
                }

                HttpCookie authCookie = HttpContext.Request.Cookies["UserInfo"];
                if (authCookie != null)
                {
                    authCookie.Values["LastLoginTime"] = Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy") + ",  " + DateTime.Now.ToString("hh:mm:ss tt"));
                    authCookie.Values["LastLoginIP"]   = sCurrentLoginIP;
                    Response.SetCookie(authCookie);
                }
            }

            #endregion

            return(View());
        }
Exemplo n.º 5
0
        public void UpdateAuthenticationDetail(M_User ObjUser)
        {
            bl_User _objUser = new bl_User();

            DateTime dCurrentLoginTime = DateTime.Now;
            string   sCurrentLoginIP   = string.Empty;

            // ********************************** // ***************************************
            string hostName = Dns.GetHostName();                                     // Retrive the Name of HOST

            sCurrentLoginIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); // Get the IP

            #region Authentication

            var vRoleName = _objLogin.GetUserRoleName(ObjUser);

            HttpCookie cookieUser = new HttpCookie("UserInfo");
            cookieUser.Values.Add("Id", Convert.ToString(ObjUser.Id));
            cookieUser.Values.Add("UserId", Convert.ToString(ObjUser.UserName));
            cookieUser.Values.Add("Name", Convert.ToString(ObjUser.Name));
            cookieUser.Values.Add("Email", Convert.ToString(ObjUser.Email));
            cookieUser.Values.Add("Phone", Convert.ToString(ObjUser.Phone));

            cookieUser.Values.Add("LastLoginTime", Convert.ToString(ObjUser.CurrentLoginTime.HasValue ? ObjUser.CurrentLoginTime.Value.ToString("dd/MM/yyyy") + ",  " + ObjUser.CurrentLoginTime.Value.ToString("hh:mm:ss tt") : "[N/A]"));
            cookieUser.Values.Add("LastLoginIP", Convert.ToString(ObjUser.LastLoginIP));
            cookieUser.Values.Add("CurrentLoginTime", Convert.ToString(dCurrentLoginTime != null ? dCurrentLoginTime.ToString("dd/MM/yyyy") + ",  " + dCurrentLoginTime.ToString("hh:mm:ss tt") : "[N/A]"));
            cookieUser.Values.Add("CurrentLoginIP", Convert.ToString(sCurrentLoginIP));
            cookieUser.Values.Add("RoleName", Convert.ToString(vRoleName));
            cookieUser.Expires = DateTime.Now.AddDays(10.0);

            Response.Cookies.Add(cookieUser);

            // Success, create non-persistent authentication cookie.
            //FormsAuthentication.SetAuthCookie(vUserObject.UserName.Trim(), false);
            //FormsAuthenticationTicket ticket1 =
            //   new FormsAuthenticationTicket(
            //        1,                          // version
            //        vUserObject.UserName.Trim(),    // get username  from the form
            //        DateTime.Now,               // issue time is now
            //        DateTime.Now.AddMinutes(10),// expires in 10 minutes
            //        false,                      // cookie is not persistent
            //        "HR"                   // role assignment is stored in userData
            //        );
            //HttpCookie cookieUser = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket1));
            //Response.Cookies.Add(cookieUser);

            #endregion

            #region Update Login Detail

            if (!string.IsNullOrWhiteSpace(Convert.ToString(ObjUser.Id)))
            {
                var vObj = _objUser.GetById(ObjUser.Id);
                if (vObj != null)
                {
                    vObj.LastLoginTime = ObjUser.CurrentLoginTime;
                    vObj.LastLoginIP   = sCurrentLoginIP;

                    vObj.CurrentLoginTime = dCurrentLoginTime;
                    vObj.CurrentLoginIP   = sCurrentLoginIP;

                    _objUser.Update(vObj);
                }
            }

            #endregion
        }