Example #1
0
        /// <summary>
        /// 保存,重置密码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try {
                string        defualtPwd = SystemSet._DEFAULTPWD;
                StringBuilder strMsgBody = new StringBuilder();
                strMsgBody.Append("您好,您的<a href=\"" + SystemSet._APPURL + "\" target=\"_parent\">");
                strMsgBody.Append("《" + SystemSet._APPAREA + SystemSet._APPTITLE + "》</a>");
                strMsgBody.Append("的登录密码已经重置为:" + defualtPwd + ",请登录系统后重新修改密码!");
                if (Common.CSendEmail.SendEmail("档案馆", txtEmail.Text.Trim(), "账号密码重置", strMsgBody.ToString(), ""))
                {
                    T_UsersInfo_MDL userMDL = userBLL.GetModelList("lower(LoginName)='" + txtUserName.Text.ToLower().Trim() + "'").FirstOrDefault();
                    if (userMDL != null)
                    {
                        userMDL.Passwd = DESEncrypt.Encrypt(defualtPwd);
                        userBLL.Update(userMDL);

                        PublicModel.writeLog(SystemSet.EumLogType.UpdData.ToString(), string.Concat("T_UsersInfo;key=", userMDL.UserID,
                                                                                                    ";UserType=", userMDL.UserType, ";CompanyID=", userMDL.CompanyID, ";UserName="******";LoginName=", userMDL.LoginName, ";找回密码"));

                        RegisterStartupScriptString("密码已经发送到您的邮箱,请及时修改!");
                    }
                }
                else
                {
                    RegisterStartupScriptString("邮件发送失败!");
                }
            } catch (Exception ex) {
                Common.LogUtil.Debug(this, "找回密码失败", ex);
                RegisterStartupScriptString("找回密码失败,请联系管理员!");
            }
        }
Example #2
0
        /// <summary>
        /// 根据公司ID获取公司用户,一个公司对应一个账号
        /// </summary>
        /// <param name="companyID"></param>
        /// <returns></returns>
        T_UsersInfo_MDL GetUserInfoMdl(string companyID)
        {
            T_UsersInfo_MDL userMdl = null;
            T_UsersInfo_BLL userBLL = new T_UsersInfo_BLL();

            IList <T_UsersInfo_MDL> ltAjMdl = userBLL.GetModelList("CompanyID=" + companyID + "");

            if (ltAjMdl != null && ltAjMdl.Count > 0)
            {
                userMdl = ltAjMdl[0];
            }
            return(userMdl);
        }
        public bool CheckOldPassword(string pwd)
        {
            bool   flag        = false;
            string LoginString = "UserID='" + Common.Session.GetSession("UserID") + "'";

            if (pwd.Trim() != "")
            {
                LoginString += " and passwd='" + DESEncrypt.Encrypt(pwd.Trim()) + "'";
                List <T_UsersInfo_MDL> userinfomdl = userinfoBLL.GetModelList(LoginString);
                if (userinfomdl.Count > 0)
                {
                    flag = true;
                }
            }
            return(flag);
        }
Example #4
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string getUserInfo(HttpContext context)
        {
            try {
                if (context.Request.Form["username"] == null || context.Request.Form["password"] == null)
                {
                    return("账号或密码为空!");
                }

                T_UsersInfo_BLL userinfobll = new T_UsersInfo_BLL();

                string strPrivateKey = string.Empty;
                using (StreamReader reader = new StreamReader(context.Server.MapPath("/RsaKey/PrivateKey.xml"))) {
                    strPrivateKey = reader.ReadToEnd();
                }

                RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
                rsa.FromXmlString(strPrivateKey);

                byte[] result = rsa.Decrypt(UserLoginGather.HexStringToBytes(context.Request.Form["password"]), false);
                System.Text.ASCIIEncoding enc = new ASCIIEncoding();
                string rsaPwd = enc.GetString(result);

                string loginString = "UPPER(loginname)='" + Common.Common.SqlSafe(context.Request.Form["username"]).ToUpper()
                                     + "' and passwd='" + DESEncrypt.Encrypt(rsaPwd) + "' ";

                List <T_UsersInfo_MDL> userinfomdl = userinfobll.GetModelList(loginString);
                if (userinfomdl.Count > 0)
                {
                    if (userinfomdl[0].IsValid == true)
                    {
                        T_Company_BLL compBLL = new T_Company_BLL();
                        T_Company_MDL compMDL = compBLL.GetModel(userinfomdl[0].CompanyID);
                        if (compMDL != null)
                        {
                            context.Session["IsCompany"]     = compMDL.IsCompany.ToString().ToLower();
                            context.Session["CompanyName"]   = compMDL.CompanyName;
                            context.Session["OLD_AREA_CODE"] = compMDL.AREA_CODE;
                            context.Session["AREA_CODE"]     = "";
                            if (compMDL.IsCompany.ToString().ToLower() == "false")     //只有档案馆,需要区域信息,建设单位等都不要过虑
                            {
                                string myArea_Code    = compMDL.AREA_CODE;
                                string myArea_CodeNew = compMDL.AREA_CODE;
                                for (int i1 = myArea_Code.Length - 1; i1 > 0; i1--)
                                {
                                    if (myArea_Code[i1].ToString() == "0")
                                    {
                                        myArea_CodeNew = myArea_Code.Substring(0, i1);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                context.Session["AREA_CODE"] = myArea_CodeNew;
                            }
                            context.Session["CompanyType"] = compMDL.CompanyType;
                        }
                        else
                        {
                            return(SystemSet._RETURN_FAILURE_VALUE + ":单位信息不存在!");
                        }

                        BLL.T_SystemInfo_BLL   systemInfoBLL = new T_SystemInfo_BLL();
                        Model.T_SystemInfo_MDL systemInfoMDL = systemInfoBLL.GetModel(compMDL.CompanyType);
                        if (systemInfoMDL == null)
                        {
                            return(SystemSet._RETURN_FAILURE_VALUE + ":单位类型字典不存在!");
                        }

                        context.Session["CompanyTypeName"] = systemInfoMDL.SystemInfoName;
                        context.Session["CompanyTypeCode"] = systemInfoMDL.SystemInfoCode;
                        context.Session["SystemInfoID"]    = systemInfoMDL.SystemInfoID;
                        context.Session["MyParentID"]      = systemInfoMDL.ParentID;

                        context.Session["UserID"]       = userinfomdl[0].UserID;
                        context.Session["LoginName"]    = userinfomdl[0].LoginName;
                        context.Session["UserName"]     = userinfomdl[0].UserName;
                        context.Session["RoleID"]       = userinfomdl[0].RoleID;
                        context.Session["CompanyID"]    = userinfomdl[0].CompanyID;
                        context.Session["IsLeader"]     = userinfomdl[0].IsLeader;
                        context.Session["SuperAdmin"]   = userinfomdl[0].IsSuperAdmin;
                        context.Session["OwnerFileTmp"] = userinfomdl[0].OwnerFileTmp;         //外协单位用户

                        T_Role_MDL roleMDL = new T_Role_BLL().GetModel(userinfomdl[0].RoleID); //签章用
                        if (roleMDL != null)
                        {
                            context.Session["RoleName"] = roleMDL.RoleName;
                            context.Session["RoleCode"] = roleMDL.RoleCode;
                        }

                        TimeSpan ts      = new TimeSpan(8760, 0, 0);
                        DateTime expired = DateTime.Today.Add(ts);
                        HttpContext.Current.Response.Cookies["LoginName"].Value   = context.Server.UrlEncode(userinfomdl[0].LoginName);
                        HttpContext.Current.Response.Cookies["LoginName"].Expires = expired;

                        //修改最后登录时间
                        userinfomdl[0].LastLoginTime = DateTime.Now;
                        userinfobll.Update(userinfomdl[0]);

                        PublicModel.writeLog(SystemSet.EumLogType.LogIn.ToString(), ";用户登录系统");
                        return(SystemSet._RETURN_SUCCESS_VALUE);
                    }
                    else
                    {
                        return("如果您已经成功注册,请等待确认后再登录!");
                    }
                }
                else
                {
                    return("用户账号或密码错误!");
                }
            } catch (Exception ex) {
                Common.LogUtil.Debug(this, "用户登录BUG", ex);
                return("系统异常,请稍后再试");
            }
        }