Exemplo n.º 1
0
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="password"></param>
 public static void UpdatePassword(string userId, string password)
 {
     Model.SUBHSSEDB db = Funs.DB;
     Model.Sys_User  m  = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
     if (m != null)
     {
         m.Password = Funs.EncryptionPassword(password);
         db.SubmitChanges();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取人员密码
        /// </summary>
        /// <param name="idCard"></param>
        /// <returns></returns>
        public static string GetPersonPassWord(string idCard)
        {
            string passWord = Funs.EncryptionPassword(Const.Password);

            ////现场人员密码
            if (!string.IsNullOrEmpty(idCard))
            {
                if (idCard.Length > 3)
                {
                    passWord = Funs.EncryptionPassword(idCard.Substring(idCard.Length - 4));
                }
                else
                {
                    passWord = Funs.EncryptionPassword(idCard);
                }
            }
            return(passWord);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 用户登录成功方法
        /// </summary>
        /// <param name="loginname">登录成功名</param>
        /// <param name="password">未加密密码</param>
        /// <param name="rememberMe">记住我开关</param>
        /// <param name="page">调用页面</param>
        /// <returns>是否登录成功</returns>
        public static bool UserLogOn(string account, string password, bool rememberMe, System.Web.UI.Page page)
        {
            List <Model.Sys_User> x = (from y in Funs.DB.Sys_User
                                       where y.Account == account && y.IsPost == true && y.Password == Funs.EncryptionPassword(password)
                                       select y).ToList();

            if (x.Any())
            {
                string accValue = HttpUtility.UrlEncode(account);
                FormsAuthentication.SetAuthCookie(accValue, false);
                page.Session[SessionName.CurrUser] = x.First();
                if (rememberMe)
                {
                    System.Web.HttpCookie u = new System.Web.HttpCookie("UserInfo");
                    u["username"] = accValue;
                    u["password"] = password;
                    // Cookies过期时间设置为一月.
                    u.Expires = DateTime.Now.AddMonths(1);
                    page.Response.Cookies.Add(u);
                }
                else
                {
                    // 当选择不保存用户名时,Cookies过期时间设置为昨天.
                    page.Response.Cookies["UserInfo"].Expires = DateTime.Now.AddDays(-1);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 用户登录成功方法
        /// </summary>
        /// <param name="loginname">登录成功名</param>
        /// <param name="password">未加密密码</param>
        /// <param name="rememberMe">记住我开关</param>
        /// <param name="page">调用页面</param>
        /// <returns>是否登录成功</returns>
        public static bool UserLogOn(string account, string password, bool rememberMe, System.Web.UI.Page page)
        {
            var getUser = from x in Funs.DB.Sys_User where x.Account == account && x.IsPost == true && x.Password == Funs.EncryptionPassword(password)
                          select new { x.UserId, x.UserName, x.Account, x.Password, SystemType = string.Empty, x.IsPost, x.LoginProjectId, LoginSystemType = string.Empty };

            ///安全登录
            if (getUser.Count() == 0)
            {
                getUser = from x in FunsHSSE.DB.Sys_User
                          where x.Account == account && x.IsPost == true && x.Password == Funs.EncryptionPassword(password)
                          select new { x.UserId, x.UserName, x.Account, x.Password, SystemType = string.Empty, x.IsPost, x.LoginProjectId, LoginSystemType = string.Empty };
                ///焊接登录
                if (getUser.Count() == 0)
                {
                    getUser = from x in FunsHJGL.DB.Sys_User
                              where x.Account == account && x.IsPost == true && x.Password == Funs.EncryptionPassword(password)
                              select new { x.UserId, x.UserName, x.Account, x.Password, SystemType = string.Empty, x.IsPost, LoginProjectId = string.Empty, LoginSystemType = string.Empty };
                    ///质量登录
                    if (getUser.Count() == 0)
                    {
                        getUser = from x in FunsCQMS.DB.Sys_User
                                  where x.Account == account && x.IsPost == true && x.Password == Funs.EncryptionPassword(password)
                                  select new { x.UserId, x.UserName, x.Account, x.Password, SystemType = string.Empty, x.IsPost, LoginProjectId = string.Empty, LoginSystemType = string.Empty };
                        ///施工技术登录
                        if (getUser.Count() == 0)
                        {
                            getUser = from x in FunsSGJS.DB.Sys_User
                                      where x.Account == account && x.IsPost == true && x.Password == Funs.EncryptionPassword(password)
                                      select new { x.UserId, x.UserName, x.Account, x.Password, SystemType = string.Empty, x.IsPost, LoginProjectId = string.Empty, LoginSystemType = string.Empty };
                            ///施工综合登录
                            if (getUser.Count() == 0)
                            {
                                getUser = from x in FunsZHGL.DB.Sys_User
                                          where x.Account == account && x.IsPost == true && x.Password == Funs.EncryptionPassword(password)
                                          select new { x.UserId, x.UserName, x.Account, x.Password, SystemType = string.Empty, x.IsPost, LoginProjectId = string.Empty, LoginSystemType = string.Empty };
                            }
                        }
                    }
                }
            }
            var firstUser = getUser.FirstOrDefault();

            if (firstUser != null)
            {
                Model.SpSysUserItem userItem = new Model.SpSysUserItem
                {
                    UserId   = firstUser.UserId,
                    UserName = firstUser.UserName,
                    Account  = firstUser.Account,
                    Password = firstUser.Password,
                };

                FormsAuthentication.SetAuthCookie(account, false);
                page.Session[SessionName.CurrUser] = userItem;
                if (rememberMe)
                {
                    System.Web.HttpCookie u = new System.Web.HttpCookie("UserInfo");
                    u["username"] = account;
                    u["password"] = password;
                    // Cookies过期时间设置为一年.
                    u.Expires = DateTime.Now.AddYears(1);
                    page.Response.Cookies.Add(u);
                }
                else
                {
                    // 当选择不保存用户名时,Cookies过期时间设置为昨天.
                    page.Response.Cookies["UserInfo"].Expires = DateTime.Now.AddDays(-1);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取用户登录信息
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public static Model.UserItem UserLogOn(Model.UserItem userInfo)
        {
            var getUser = Funs.DB.View_Sys_User.FirstOrDefault(x => (x.Account == userInfo.Account || x.Telephone == userInfo.Telephone) && x.IsPost == true && x.Password == Funs.EncryptionPassword(userInfo.Password));

            return(ObjectMapperManager.DefaultInstance.GetMapper <Model.View_Sys_User, Model.UserItem>().Map(getUser));
        }