Example #1
0
 public ActionResult UserPhotoUpdate(HttpPostedFileBase file_1, string isuserphoto)
 {
     if (file_1 != null)
     {
         if (file_1.ContentLength == 0)
         {
             //文件大小(以字节为单位)为0,返回到视图
             return(RedirectToAction("UserIndex"));
         }
         else
         {
             UserInfo user     = Session["user"] as UserInfo;
             string   fileName = Path.GetFileName(file_1.FileName);
             if (isuserphoto == "0")
             {
                 UserInfoBll.UpdateUserPhoto(fileName, user.UserID, true);
             }
             else
             {
                 UserInfoBll.UpdateUserPhoto(fileName, user.UserID, false);
             }
             Session["user"] = UserInfoBll.SelectUser(user.UserID);
             //保存文件
             //应用程序需要有服务器UploadFile文件夹的读写权限
             file_1.SaveAs(Server.MapPath("~/Content/Images/" + fileName));
         }
     }
     return(RedirectToAction("UserIndex"));
 }
Example #2
0
        /// <summary>
        /// 修改用户名
        /// </summary>
        /// <param name="token">token或用户id</param>
        /// <param name="username"></param>
        /// <returns></returns>
        public IHttpActionResult ChangeUsername(string token, string username)
        {
            UserInfoDto user;

            if (Guid.TryParse(token, out var userid))
            {
                //session登录
                user = UserInfoBll.GetById(userid).Mapper <UserInfoDto>();
            }
            else
            {
                //api登录
                if (!RedisHelper.KeyExists(token))
                {
                    return(ResultData(null, false, "用户未登录系统!"));
                }
                user = RedisHelper.GetString <UserInfoDto>(token);
            }
            var userInfo = UserInfoBll.GetById(user.Id);

            if (!username.Equals(userInfo.Username) && UserInfoBll.UsernameExist(username))
            {
                return(ResultData(null, false, $"用户名{username}已经存在,请尝试更换其他用户名!"));
            }
            userInfo.Username = username;
            bool b = UserInfoBll.UpdateEntitySaved(userInfo);

            return(ResultData(Mapper.Map <UserInfoDto>(userInfo), b, b ? $"用户名修改成功,新用户名为{username}。" : "用户名修改失败!"));
        }
        public ActionResult AddAdminUser(FormCollection form)
        {
            string   pwd    = form["pwd"];
            string   MD5Pwd = Md5Helper.GetMd5(pwd);
            UserInfo user   = new UserInfo()
            {
                UName           = form["uName"].ToString(),
                Pwd             = MD5Pwd,
                Name            = form["name"].ToString(),
                Tel             = form["tel"].ToString(),
                InTime          = DateTime.Now,
                Last_login_Time = DateTime.Now
            };

            if (user != null)
            {
                UserInfoBll.Add(user);

                string guid = Request["actionKey"];
                if (!string.IsNullOrEmpty(guid))
                {
                    var data = Common.CacheHelper.Get(guid) as List <ActionInfo>;
                    Common.CacheHelper.Remove(guid, data, DateTime.Now.AddDays(-1));
                }
                return(Content("ok"));
            }
            else
            {
                return(Content("fail"));
            }
        }
        public ActionResult Edit(string UName, string Pwd, string Name, string Tel, int id)
        {
            var userUpdate = UserInfoBll.LoadEntities(u => u.Id == id).FirstOrDefault();

            if (userUpdate != null)
            {
                userUpdate.UName = UName;
                if (!string.IsNullOrEmpty(Pwd))
                {
                    string MD5Pwd = Md5Helper.GetMd5(Pwd);
                    userUpdate.Pwd = MD5Pwd;
                }
                userUpdate.Name = Name;
                userUpdate.Tel  = Tel;
                if (UserInfoBll.Update(userUpdate))
                {
                    return(Content("ok"));
                }
                else
                {
                    return(Content("修改失败"));
                }
            }
            return(Content("数据为空"));
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            UserInfoBll userBll = new UserInfoBll();
            DataTable   dt      = userBll.SelectUserByEmail(txtEmail.Text.Trim());

            if (dt.Rows.Count > 0)
            {
                string strUserId   = dt.Rows[0]["UserID"].ToString();
                string strUsername = dt.Rows[0]["UserName"].ToString();
                string strPassword = dt.Rows[0]["UserPassword"].ToString();

                string mUname       = ConfigurationManager.AppSettings["mailUsername"].ToString();
                string mPwd         = ConfigurationManager.AppSettings["mailPassword"].ToString();
                string mFrom        = "";
                string mTo          = txtEmail.Text.Trim();
                string mCC          = "";
                string mSubject     = "Yard E-Cart Password request";
                string serverPath   = ConfigurationManager.AppSettings["ApplicationPath"].ToString() + "/Login.aspx";
                string activatePath = ConfigurationManager.AppSettings["ApplicationPath"].ToString() + "/ActivateUser.aspx?uid=" + UtilityClass.Encrypt(strUserId.ToString()).ToString();
                string resetPath    = ConfigurationManager.AppSettings["ApplicationPath"].ToString() + "/ResetPassword.aspx?uid=" + UtilityClass.Encrypt(strUserId.ToString()).ToString();

                string mMsg = "";

                if (dt.Rows[0]["UserStatus"].ToString() == "0")
                {
                    mMsg = "<html><body><form id='form1' runat='server'><div>" +
                           "Dear " + strUsername + ",<br /><br />As you request, your username and password is given below:<br><br>" +
                           "<b>UserName : "******"<br>Password : "******"</b>" +
                           "<br /><br />Before we can activate your account one last step must be taken to complete your registration." +
                           "<br /><br />Please note - you must complete this last step to become a registered member. You will only need to visit this URL once to activate your account." +
                           "<br /><br />To complete your registration, please visit this URL:<br />" +
                           "<a href='" + activatePath + "' runat='server' >" + activatePath + "</a>" +
                           "<br /><br />Now you can login with Yard E-Cart<br />" +
                           "<a href='" + serverPath + "' runat='server' >" + serverPath + "</a>" +
                           "<br /><br />Or you can reset password with below link<br />" +
                           "<a href='" + resetPath + "' runat='server' >" + resetPath + "</a>" +
                           "<br /><br /><br /><br />All the best,<br />Yard E-Cart.</div></form></body></html>";
                }
                else
                {
                    mMsg = "<html><body><form id='form1' runat='server'><div>" +
                           "Dear " + strUsername + ",<br /><br />As you request, your username and password is given below:<br><br>" +
                           "<b>UserName : "******"<br>Password : "******"</b>" +
                           "<br /><br />Now you can login with Yard E-Cart<br />" +
                           "<a href='" + serverPath + "' runat='server' >" + serverPath + "</a>" +
                           "<br /><br />Or you can reset password with below link<br />" +
                           "<a href='" + resetPath + "' runat='server' >" + resetPath + "</a>" +
                           "<br /><br /><br /><br />All the best,<br />Yard E-Cart.</div></form></body></html>";
                }
                UtilityClass.SendMail(mUname, mPwd, mFrom, mTo, mCC, mSubject, mMsg, true);

                tblMessage.InnerText = "User Name and Password are sending to " + txtEmail.Text.Trim() + ". Check your mail..";
                txtEmail.Text        = "";
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = "Please enter your correct E-mail address.";
            }
        }
Example #6
0
        void LoadUserInfo()
        {
            UserInfoBll userBll = new UserInfoBll();
            DataTable   dt      = userBll.SelectProfile(Convert.ToInt32(Session["UserId"].ToString()));

            if (dt.Rows.Count > 0)
            {
                lblName.Text = dt.Rows[0]["FirstName"].ToString() + " " + dt.Rows[0]["LastName"].ToString();
                if (dt.Rows[0]["Gender"].ToString() == "1")
                {
                    lblGender.Text = "Male";
                }
                else if (dt.Rows[0]["Gender"].ToString() == "2")
                {
                    lblGender.Text = "Female";
                }
                else if (dt.Rows[0]["Gender"].ToString() == "0")
                {
                    lblGender.Text = "Rather not say";
                }
                lblEmail.Text      = dt.Rows[0]["Email"].ToString();
                lblMobile.Text     = dt.Rows[0]["Mobile"].ToString();
                lblAddress.Text    = dt.Rows[0]["Address"].ToString();
                lblStreetname.Text = dt.Rows[0]["StreetName"].ToString();
                lblCountry.Text    = dt.Rows[0]["CountryName"].ToString();
                lblCity.Text       = dt.Rows[0]["CityName"].ToString();
                lblState.Text      = dt.Rows[0]["StateName"].ToString();
                lblZipcode.Text    = dt.Rows[0]["ZipCode"].ToString();
            }
        }
Example #7
0
        public JsonResponse SignIn([FromBody] SignInDto dto)
        {
            if (dto.Email == null || dto.Password == null || dto.Verify == null || dto.VerifyId == null)
            {
                return(BadResponse("参数提供不完整"));
            }
            //判断验证码是否输入正确
            if (!TokenHelper.CheckVerify(dto.VerifyId, dto.Verify))
            {
                return(BadResponse("验证码错误"));
            }
            //检查用户名密码是否正确
            UserInfo model = new UserInfo();

            model = UserInfoBll.GetModelByEmail(dto.Email);
            if (model == null)
            {
                return(BadResponse("用户不存在", null));
            }
            //检查用户是否登录,若有登录信息则刷新时间
            //判断用户是否登录
            if (!TokenHelper.CheckLoginStateByUserId(model.Id))
            {
                LoginState loginState = new LoginState
                {
                    UserId    = model.Id,
                    StartTime = DateTime.Now
                };
                LoginStateBll.Insert(loginState);
            }
            return(OkResponse(null));
        }
Example #8
0
        public JsonResponse SingUp([FromBody] UserInfo model)
        {
            if (model.Email == null || model.Password == null || model.Nickname == null)
            {
                return(BadResponse("参数提供不完整"));
            }
            //检查邮箱是否可用
            JsonResponse emailModel = CheckUser(model.Email);

            if (!emailModel.Success)
            {
                return(BadResponse(emailModel.Message));
            }
            //检查昵称是否可用
            JsonResponse nicknameModel = CheckUser(model.Email);

            if (!nicknameModel.Success)
            {
                return(BadResponse(nicknameModel.Message));
            }
            //密码加密
            model.Password = PasswordHelper.PwdStrToHashStr(model.Password);
            //写入数据库
            if (UserInfoBll.Insert(model))
            {
                return(OkResponse(null));
            }
            else
            {
                return(BadResponse("注册失败,请重试"));
            }
        }
Example #9
0
 public FrmMain()
 {
     userInfoBll = new UserInfoBll();
     orderBll    = new OrderBll();
     userInfos   = new List <UserInfo>();
     InitializeComponent();
 }
Example #10
0
 /// <summary>
 /// 用户注册
 /// </summary>
 /// <param name="UserName">用户名</param>
 /// <param name="UserPwd">密码</param>
 /// <param name="UserCard">身份证号</param>
 /// <param name="UserPhont">电话</param>
 /// <param name="UserEmail">邮箱</param>
 /// <param name="Yzm">用户输入的验证码</param>
 /// <returns></returns>
 public JsonResult RegistAjax(string UserName, string UserPwd, string UserCard, string UserPhont, string UserEmail, string Yzm)
 {
     //判断验证码是否输入正确
     if (Session["yzm"].ToString().Trim().ToLower() == Yzm.Trim().ToLower())
     {
         UserInfo user = new UserInfo()
         {
             UserName         = UserName,
             UserPassword     = UserPwd,
             UserAccount      = UserPhont,
             UserEmail        = UserEmail,
             UserAge          = UserCard.GetUserBirthdays().GetUserAge(),
             UserSex          = UserCard.GetUserSex(),
             UserPhont        = UserPhont,
             UserCard         = UserCard,
             UserBirthdays    = UserCard.GetUserBirthdays(),
             ReceivingAddress = ""
         };
         if (UserInfoBll.AddUserInfo(user))
         {
             //注册成功
             return(Json(1, JsonRequestBehavior.AllowGet));
         }
     }
     //注册失败
     return(Json(0, JsonRequestBehavior.AllowGet));
 }
Example #11
0
        //完成对用户角色的分配
        public ActionResult SetUserRole()
        {
            var userId = int.Parse(Request["userId"]);

            //Post请求中的表单元素以键值对表示
            //[name,value],key是name;所以要递交的表单元素必须要有name.
            var allKeys = Request.Form.AllKeys;//获取Post请求中Form表单元素所有的键(name)
            var idList  = new List <int>();

            foreach (string key in allKeys)
            {
                if (key.StartsWith("cba_"))
                {
                    var id = int.Parse(key.Replace("cba_", ""));
                    idList.Add(id);
                }
            }

            var result = "";

            if (UserInfoBll.SetUserOrderInfo(userId, idList))
            {
                result = "ok";
            }
            else
            {
                result = "no";
            }

            return(Content(result));
        }
Example #12
0
        public override void SubProcessRequest(HttpContext context)
        {
            #region 接收参数
            //接收参数
            string strUserId     = Context.Request.Form["UserId"];
            string strUsername   = Context.Request.Form["Username"];
            string strPassword   = Context.Request.Form["Password"];
            string strRealName   = Context.Request.Form["RealName"];
            string strPhone      = Context.Request.Form["Phone"];
            string strUserType   = Context.Request.Form["UserType"];
            string strStatus     = Context.Request.Form["Status"];
            string strCreateDate = Context.Request.Form["CreateDate"];
            #endregion

            UserInfoBll bllUserInfo = new UserInfoBll();

            #region 实体赋值
            //实体赋值
            oyxf.Model.UserInfo model = new Model.UserInfo();
            if (!string.IsNullOrWhiteSpace(strUserId) && strUserId.IsNumber())
            {
                //修改
                model.UserId = Convert.ToInt32(strUserId);
            }

            model.Username = !string.IsNullOrWhiteSpace(strUsername) ? strUsername : "";
            model.RealName = !string.IsNullOrWhiteSpace(strRealName) ? strRealName : "";
            model.Phone    = !string.IsNullOrWhiteSpace(strPhone) ? strPhone : "";
            model.UserType = (!string.IsNullOrWhiteSpace(strUserType) && strUserType.IsNumber()) ? Convert.ToInt32(strUserType) : 0;
            model.Status   = (!string.IsNullOrWhiteSpace(strStatus) && strStatus.IsNumber()) ? Convert.ToInt32(strStatus) : 0;

            //创建时间
            model.CreateDate = !string.IsNullOrWhiteSpace(strCreateDate)
                ? DateTime.ParseExact(strCreateDate, "yyyy-MM-dd HH:mm:ss:fff", System.Globalization.CultureInfo.CurrentCulture)
                : DateTime.Now;

            //密码
            model.Password = !string.IsNullOrWhiteSpace(strPassword) ? strPassword.ToUpper() : "";
            #endregion

            #region 用户名是否重复
            //用户名是否重复
            if (bllUserInfo.IsExistUsername(model))
            {
                AjaxHelper.WriteError(msg: "用户名已存在");
            }
            #endregion

            #region 新增或修改
            //新增或修改
            if (bllUserInfo.AddOrUpdate(model))
            {
                AjaxHelper.WriteSuccess();
            }
            else
            {
                AjaxHelper.WriteError(msg: "操作失败");
            }
            #endregion
        }
        public async Task <IHttpActionResult> ResetPassword01_CheckUserName(string username)
        {
            JsonResult <string> result = new JsonResult <string>();

            result.code = 0;
            result.msg  = "OK";
            if (username.IsNull())
            {
                result.Result = "用户名不能为空";
                return(Ok(result));
            }
            result.Result = await Task.Run <string>(() => {
                string tel        = string.Empty;
                UserInfoBll ubll  = new UserInfoBll();
                UserInfo userinfo = ubll.GetByUserName(username);
                if (userinfo != null)
                {
                    result.code = 1;
                    result.msg  = "OK";
                    if (!string.IsNullOrEmpty(userinfo.Telephone) && userinfo.Telephone.IsMobile())
                    {
                        tel             = string.Format("{0}*****{1}", userinfo.Telephone.Substring(0, 3), userinfo.Telephone.Substring(8));
                        string cachekey = cookieKey();
                        RedisBase.Item_Set(cachekey, userinfo.Telephone);
                        RedisBase.ExpireEntryAt(cachekey, DateTime.Now.AddMinutes(10));
                        result.ResultMsg = cachekey;
                        return(tel);
                    }
                }
                return(tel);
            });

            return(Ok(result));
        }
Example #14
0
        /// <summary>
        /// 后台评论分布视图
        /// </summary>
        /// <returns></returns>
        public ActionResult BackCommentPartial(int?pageindex, int?SelectType)
        {
            int index = SelectType ?? 0;
            List <CommentTable> list = new List <CommentTable>();

            if (index == 0)
            {
                list = CommentBll.SelectAllComment().OrderByDescending(p => p.IsTop).ToList();
            }
            else if (index == 5)
            {
                //查询违规评论
                list = CommentBll.SelectAllComment().Where(p => p.Reportingnums > 0).OrderByDescending(p => p.IsTop).OrderByDescending(p => p.Reportingnums).ToList();
            }
            else
            {
                //查询第一大类的商品评论
                list = CommentBll.SelectByTidComment(index).OrderByDescending(p => p.IsTop).ToList();
                //增加userinfo对象,防止报错
                list.ForEach(p => p.UserInfo = UserInfoBll.SelectUser(p.UserID ?? 1));
            }
            if (list != null && list.Count() > 0)
            {
                Session["plcount"] = list.Count();
            }
            else
            {
                Session["plcount"] = 0;
            }
            ViewBag.SelectType     = index;
            ViewBag.pageindex      = pageindex ?? 1;
            Session["plpagecount"] = Math.Ceiling(list.Count() / 10.0);
            Session["allpl"]       = list.Skip(((pageindex ?? 1) - 1) * 10).Take(10).ToList();
            return(PartialView("BackCommentPartial"));
        }
        /// <summary>
        /// 获取用户菜单、访问控制
        /// </summary>
        /// <param name="id"></param>
        /// <param name="appid"></param>
        /// <returns></returns>
        public ActionResult GetUserAuthority(Guid id, string appid)
        {
            List <MenuOutputDto>    menus    = UserInfoBll.GetMenus(appid, id);
            List <ControlOutputDto> controls = UserInfoBll.GetAccessControls(appid, id);

            return(ResultData(new { menus, controls }));
        }
        /// <summary>
        /// 获取用户列表分页
        /// </summary>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="kw"></param>
        /// <param name="appid"></param>
        /// <returns></returns>
        public ActionResult Page(int page = 1, int size = 10, string kw = "", string appid = "")
        {
            Expression <Func <UserInfo, bool> > @where;

            if (string.IsNullOrEmpty(kw))
            {
                if (string.IsNullOrEmpty(appid))
                {
                    where = u => true;
                }
                else
                {
                    where = u => u.ClientApp.Any(a => a.AppId.Equals(appid));
                }
            }
            else
            {
                if (string.IsNullOrEmpty(appid))
                {
                    where = u => u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw);
                }
                else
                {
                    where = u => u.ClientApp.Any(a => a.AppId.Equals(appid)) && u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw);
                }
            }

            List <UserInfoDto> list = UserInfoBll.LoadPageEntitiesNoTracking <DateTime, UserInfoDto>(page, size, out int total, where, u => u.LastLoginTime, false).ToList();

            return(PageResult(list, size, total));
        }
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="old"></param>
        /// <param name="pwd"></param>
        /// <param name="confirm"></param>
        /// <returns></returns>
        public ActionResult ChangePassword(string old, string pwd, string confirm)
        {
            if (pwd.Length <= 6)
            {
                return(ResultData(null, false, "密码过短,至少需要6个字符!"));
            }

            if (!pwd.Equals(confirm))
            {
                return(ResultData(null, false, "两次输入的密码不一致!"));
            }

            var regex = new Regex(@"(?=.*[0-9])                     #必须包含数字
                                            (?=.*[a-zA-Z])                  #必须包含小写或大写字母
                                            (?=([\x21-\x7e]+)[^a-zA-Z0-9])  #必须包含特殊符号
                                            .{6,30}                         #至少6个字符,最多30个字符
                                            ", RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);

            if (regex.Match(pwd).Success)
            {
                bool b = UserInfoBll.ChangePassword(CurrentUser.Id, old, pwd);
                return(ResultData(null, b, b ? $"密码修改成功,新密码为:{pwd}!" : "密码修改失败,可能是原密码不正确!"));
            }

            return(ResultData(null, false, "密码强度值不够,密码必须包含数字,必须包含小写或大写字母,必须包含至少一个特殊符号,至少6个字符,最多30个字符!"));
        }
        public JsonResponse AccountUserList([FromUri] string Code, string UserId)
        {
            //判断用户是否登录
            if (!TokenHelper.CheckLoginStateByUserId(UserId))
            {
                return(BadResponse("用户未登录", null, false));
            }
            AccountList model = new AccountList();

            model = AccountListBll.GetModelByCode(Code);
            string[]        allUserIdArray = model.AllUserId.Split(',');
            List <UserInfo> AllUserList    = UserInfoBll.GetListByIdList(allUserIdArray).ToList();

            List <AccountListAllUserDto> returnList = new List <AccountListAllUserDto>();

            foreach (var user in AllUserList)
            {
                AccountListAllUserDto userModel = new AccountListAllUserDto
                {
                    NickName = user.Nickname,
                    UserId   = user.Id
                };
                returnList.Add(userModel);
            }
            return(OkResponse(returnList, "请求成功!"));
        }
Example #19
0
        /// <summary>
        /// 展示数据
        /// </summary>
        /// <returns></returns>
        public ActionResult GetUserInfoList()
        {
            //请求报文里有两个参数:page和rows
            int pageIndex = Request["page"] == null ? 1 : int.Parse(Request["page"]);
            int pageSize  = Request["rows"] == null ? 5 : int.Parse(Request["rows"]);
            //var temp = Bll.LoadPageEntities<int>(pageIndex, pageSize, out int pageCount, true, u => u.DelFlag == (short)DeleteEnumType.Normal, u => u.ID);
            UserInfoSearch userInfoSearch = new UserInfoSearch()
            {
                PageIndex  = pageIndex,
                PageSize   = pageSize,
                UserName   = Request["name"],
                UserRemark = Request["remark"]
            };
            //执行完下面这个方法后userInfoSearch.PageCount才有值
            var temp         = UserInfoBll.LoadSearchEntities(userInfoSearch, DeleteEnumType.Normal);
            var userInfoList = from u in temp
                               select new
            {
                //下面可以注释的原因:自己看吧
                /*ID = */
                u.ID,
                /*UName = */
                u.UName,
                /*UPwd = */
                u.UPwd,
                /*Remark = */
                u.Remark,
                SubTime = u.SubTime
            };

            return(Json(new { total = userInfoSearch.PageCount, rows = userInfoList }));
        }
Example #20
0
        //将待办事项数据加入到集合中
        private void AddEntryViewToList(List <QuickEntryViewModel> ltEntry, IQueryable <WFInstance> instances)
        {
            var uuList = UserInfoBll.GetList <long>(u => true).ToList();

            if (instances != null && instances.Count() > 0)
            {
                foreach (var item in instances)
                {
                    string rejectBy = item.SubBy + "";
                    var    subBy    = uuList.Where(uu => uu.UserId == long.Parse(rejectBy)).FirstOrDefault();
                    if (item.InstanceState == 2)
                    {
                        //已完成
                        continue;
                    }
                    else if (item.InstanceState == 1)
                    {
                        //驳回
                        rejectBy = item.WFStep.OrderByDescending(s => s.StepId).FirstOrDefault().SubBy.ToString();
                    }
                    ltEntry.Add(new QuickEntryViewModel()
                    {
                        InstanceId    = item.InstanceId,
                        InstanceTitle = item.InstanceTitle,
                        InstanceState = item.InstanceState,
                        SubBy         = subBy.RealName != null && subBy.RealName != "" ?  subBy.RealName :  subBy.Username
                    });
                }
            }
        }
Example #21
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            //获取用户输入的信息
            string name = cb_user.Text.Trim();
            string pwd  = txt_password.Text.Trim();

            UserInfoBll uiBll      = new UserInfoBll();
            LoginState  loginState = uiBll.Login(name, pwd);

            switch (loginState)
            {
            case LoginState.Ok:
                //将员工级别传递过去
                UserInfo.CurrentLevel = UserInfo.UserLevel.Technician;
                LoginEvent.Invoke("工程师");
                this.Close();
                break;

            case LoginState.NameError:
                MessageBox.Show("用户名错误");
                break;

            case LoginState.PwdError:
                MessageBox.Show("密码错误");
                break;
            }
        }
Example #22
0
        //获取审批人下拉列表数据
        private List <SelectListItem> GetNextIdList()
        {
            UserInfo userInfo = UserInfoBll.GetById(UserLogin.UserId);
            List <SelectListItem> ltResult = new List <SelectListItem> {
                new SelectListItem()
            };

            if (userInfo != null && userInfo.RoleInfo != null)
            {
                List <RoleInfo> ltRole = userInfo.RoleInfo.ToList();
                byte            temp   = 0;
                foreach (var item in ltRole)
                {
                    temp = item.RoleLevel > temp ? item.RoleLevel : temp;
                }
                IQueryable <RoleInfo> ltR = RoleInfoBll.GetList(r => (r.RoleLevel == temp + 1), r => r.RoleName);
                ltResult = (from r in ltR
                            from u in r.UserInfo
                            select new SelectListItem
                {
                    Text = u.Username + "(" + r.RoleName + ")",
                    Value = u.UserId + ""
                }).ToList();
                if (ltResult.Count > 0)
                {
                    ltResult.Add(new SelectListItem {
                        Text = "---默认---", Value = ltResult[0].Value, Selected = true
                    });
                }
            }
            return(ltResult);
        }
Example #23
0
        protected void ShowData()
        {
            string id = Request["UserId"];

            if (!string.IsNullOrEmpty(id))
            {
                this.trPwd.Visible = false;
                UserInfoBll bll   = new UserInfoBll();
                UserInfo    model = bll.GetModel(Convert.ToInt32(id));
                if (model != null)
                {
                    this.txtUserName.Text = model.UserName;
                    //this.txtAdminPwd.Text = model.AdminPwd;
                    string[] roleIds = model.RoleId.Split(',');
                    for (int i = 0; i < this.chkListRole.Items.Count; i++)
                    {
                        for (int j = 0; j < roleIds.Length; j++)
                        {
                            if (chkListRole.Items[i].Value == roleIds[j])
                            {
                                chkListRole.Items[i].Selected = true;
                            }
                        }
                    }
                    this.rdoList.SelectedValue = model.IsLock.ToString();
                    this.txtDesc.Text          = model.Desc;
                }
            }
        }
Example #24
0
        /// <summary>
        /// 获取角色的用户
        /// </summary>
        /// <param name="id"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="kw"></param>
        /// <param name="appid"></param>
        /// <returns></returns>
        public ActionResult Users(int id, int page = 1, int size = 10, string kw = "", string appid = "")
        {
            Expression <Func <UserInfo, bool> > where;
            if (!string.IsNullOrEmpty(kw))
            {
                if (string.IsNullOrEmpty(appid))
                {
                    where = u => u.Role.Any(c => c.Id == id) && (u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw));
                }
                else
                {
                    where = u => u.ClientApp.Any(c => c.AppId.Equals(appid)) && u.Role.Any(c => c.Id == id) && (u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw));
                }
            }
            else
            {
                if (string.IsNullOrEmpty(appid))
                {
                    where = u => u.Role.Any(c => c.Id == id);
                }
                else
                {
                    where = u => u.ClientApp.Any(c => c.AppId.Equals(appid)) && u.Role.Any(c => c.Id == id);
                }
            }
            List <UserInfoDto> my = UserInfoBll.LoadPageEntities <DateTime, UserInfoDto>(page, size, out int total, where, u => u.LastLoginTime, false).ToList();//属于该应用

            return(PageResult(my, size, total));
        }
Example #25
0
        //获取分页数据
        public ActionResult GetApprove()
        {
            long     searchId;
            bool     isId = long.TryParse(Request["searchId"], out searchId);
            string   searchName = string.IsNullOrEmpty(Request["searchName"]) ? string.Empty : Request["searchName"];
            DateTime from, to;
            bool     fromIsDate = DateTime.TryParse(Request["from"], out from);
            bool     toIsDate   = DateTime.TryParse(Request["to"], out to);
            string   fromStr    = from.ToString("yyyy-MM-dd HH:mm:ss");
            string   toStr      = to.ToString("yyyy-MM-dd") + " 23:59:59";

            int pageIndex = Request["page"] != null?int.Parse(Request["page"]) : 1;

            int pageSize = Request["rows"] != null?int.Parse(Request["rows"]) : 5;

            int totalCount;
            var stepList = WFStepBll.GetPageList <long>(s => (s.NextId == UserLogin.UserId) && (s.IsEnd == 0) && (isId ? s.InstanceId == searchId : true) && (searchName != string.Empty ? s.WFInstance.InstanceTitle.Contains(searchName) : true) && (fromIsDate ? fromStr.CompareTo(s.WFInstance.SubTime) <= 0 : true) && (toIsDate ? toStr.CompareTo(s.WFInstance.SubTime) >= 0 : true), s => s.InstanceId, false, pageIndex, pageSize, out totalCount);
            var uList    = UserInfoBll.GetList <int>(us => true);
            var result   = from i in stepList
                           from uu in uList
                           where i.SubBy == uu.UserId
                           select new
            {
                StepId        = i.StepId,
                InstanceId    = i.InstanceId,
                InstanceTitle = i.WFInstance.InstanceTitle,
                Details       = i.WFInstance.Details,
                Remark        = i.WFInstance.Remark,
                SubTime       = i.SubTime,
                SubBy         = uu.RealName != null && uu.RealName != "" ? uu.RealName : uu.Username
            };

            return(Json(new { total = totalCount, rows = result }, JsonRequestBehavior.AllowGet));
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            UserInfo userInfo = GetModel();

            UserInfoBll bll = new UserInfoBll();

            if (UserId == 0)
            {
                DepartmentBll departmentBll = new DepartmentBll();
                DepartmentInfo departmentInfo = departmentBll.GetDepartmentById(DepartmentId);
                if (departmentInfo != null && departmentInfo.DepartmentId > 0)
                {
                    userInfo.DepartmentCode = departmentInfo.DepartmentCode;
                }
                bll.AddUserInfo(userInfo);

            }
            else
            {
                userInfo.UserId = UserId;
                bll.Update(userInfo);
            }

            Page.RegisterClientScriptBlock("", "<script>alert('保存成功');CloseWin();</script>");
        }
Example #27
0
        public JsonResult SeachList(string name, int page, int pageSize)
        {
            //string name = Request.Form["name"];

            ListPage    lp   = new ListPage();
            UserInfoBll uBll = new UserInfoBll();

            page = page <= 0 ? 1 : page;
            //索引页
            int iPageIndex = page - 1;
            //总记录数量
            int count = 0;

            var list = uBll.SearchByList(name.Trim(), ref count).Skip(iPageIndex * pageSize).Take(pageSize).ToList();

            pageSize = pageSize == 0 ? count : pageSize;
            int pageCount = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;

            //lp.PageSize = pageSize;
            lp.CurrentPage = page;
            lp.TotalRecord = count;
            lp.PageCount   = pageCount;
            lp.Data        = list;

            return(Json(lp));
        }
Example #28
0
        void LoadUsers()
        {
            objUser = new UserInfoBll();
            if (txtSearch.Text.ToString().Trim() == "")
            {
                dt = objUser.SelectAllProfile();
            }
            else
            {
                dt = objUser.SearchUsers(txtSearch.Text.ToString().Trim());
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();

            if (dt.Rows.Count > 0)
            {
                tblUser.Visible  = true;
                lblError.Visible = false;
            }
            else
            {
                tblUser.Visible  = false;
                lblError.Visible = true;
                lblError.Text    = "No Users";
            }
        }
Example #29
0
        /// <summary>
        /// 验证Cookie
        /// </summary>
        private void CheckCookie()
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[Key.COOKIE_CURRENTUSER];

            if (cookie == null)
            {
                ScriptHelper.AlertRedirect("您还未登录", "/login.aspx");
                return;
            }
            if (string.IsNullOrWhiteSpace(cookie.Value))
            {
                ScriptHelper.AlertRedirect("您还未登录", "/login.aspx");
                return;
            }
            string UserIdStr = CryptoHelper.TripleDES_Decrypt(cookie.Value, Key.TRIPLEDES_KEY);

            if (!UserIdStr.IsNumber())
            {
                ScriptHelper.AlertRedirect("您还未登录", "/login.aspx");
                return;
            }
            int userid = Convert.ToInt32(UserIdStr);

            UserInfoBll bll = new UserInfoBll();

            oyxf.Model.UserInfo ui = bll.GetModel(userid);
            if (ui == null)
            {
                ScriptHelper.AlertRedirect("您还未登录", "/login.aspx");
                return;
            }
            HttpContext.Current.Session[Key.SESSION_CURRENTUSER] = ui;
        }
        private void InitData()
        {
            ProjectBll projectBll = new ProjectBll();

            ProjectInfo projectInfo = projectBll.GetProjectById(ProjectId);

            if (projectInfo != null)
            {
                lblProjectName.Text = projectInfo.ProjectName;
                if (projectInfo.CustomerId > 0)
                {
                    CustomerBll customerBll = new CustomerBll();

                    CustomerInfo customerInfo = customerBll.GetCustomerById(projectInfo.CustomerId);

                    if (customerInfo != null)
                    {
                        lblCustomerName.Text = customerInfo.CustomerName;
                    }
                }
                if (projectInfo.BussinessUserId > 0)
                {
                    UserInfoBll userInfoBll = new UserInfoBll();

                    UserInfo userInfo = userInfoBll.GetUserListById(projectInfo.BussinessUserId);

                    if (userInfo != null)
                    {
                        lblBusinessName.Text = userInfo.UserName;
                    }
                }

                if (projectInfo.ResponseUserId > 0)
                {
                    UserInfoBll userInfoBll = new UserInfoBll();

                    UserInfo userInfo = userInfoBll.GetUserListById(projectInfo.ResponseUserId);

                    if (userInfo != null)
                    {
                        lblResponseName.Text = userInfo.UserName;
                    }

                    hidUserId.Value = projectInfo.ResponseUserId.ToString();
                }

                if (projectInfo.CreatedUserId > 0)
                {
                    UserInfoBll userInfoBll = new UserInfoBll();

                    UserInfo userInfo = userInfoBll.GetUserListById(projectInfo.CreatedUserId);

                    if (userInfo != null)
                    {
                        lblCreateUser.Text = userInfo.UserName;
                    }
                }

            }
        }
Example #31
0
        //获取分页数据
        public ActionResult GetPageList()
        {
            long     searchId;
            bool     isId = long.TryParse(Request["searchId"], out searchId);
            string   searchName = string.IsNullOrEmpty(Request["searchName"]) ? string.Empty : Request["searchName"];
            DateTime from, to;
            bool     fromIsDate = DateTime.TryParse(Request["from"], out from);
            bool     toIsDate   = DateTime.TryParse(Request["to"], out to);
            bool     showAll    = !string.IsNullOrEmpty(Request["show"]);

            int pageIndex = Request["page"] != null?int.Parse(Request["page"]) : 1;

            int pageSize = Request["rows"] != null?int.Parse(Request["rows"]) : 5;

            int totalCount;
            WhereHelper <WFInstance> wh = new WhereHelper <WFInstance>();

            //wh.Equal("IsDeleted", (byte)0);
            if (!showAll)
            {
                wh.Equal("SubBy", UserLogin.UserId);
            }
            if (isId)
            {
                wh.Equal("InstanceId", searchId);
            }
            if (searchName != string.Empty)
            {
                wh.Contains("InstanceTitle", searchName);
            }
            if (fromIsDate)
            {
                wh.StrGreater("SubTime", from.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            if (toIsDate)
            {
                wh.StrLess("SubTime", to.ToString("yyyy-MM-dd") + " 23:59:59");
            }
            var InstanceList = WFInstanceBll.GetPageList <long>(wh.GetExpression(), i => i.InstanceId, false, pageIndex, pageSize, out totalCount);
            var uList        = UserInfoBll.GetList <int>(us => true);
            var result       = from i in InstanceList
                               from uu in uList
                               where i.SubBy == uu.UserId
                               select new
            {
                UserId        = UserLogin.UserId,
                SubId         = i.SubBy,
                InstanceId    = i.InstanceId,
                InstanceTitle = i.InstanceTitle,
                InstanceState = i.InstanceState,
                Details       = i.Details,
                Remark        = i.Remark,
                SubTime       = i.SubTime,
                SubBy         = uu.RealName != null && uu.RealName != "" ? uu.RealName : uu.Username,
                RejectMsg     = i.RejectMsg
            };

            return(Json(new { total = totalCount, rows = result }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>在调用操作方法前调用。</summary>
        /// <param name="filterContext">有关当前请求和操作的信息。</param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
#if !DEBUG
            var user = UserInfoBll.GetByUsername("admin").Mapper <UserInfoDto>();
            CurrentUser = user;
            Session.SetByRedis(user);
#endif
        }
Example #33
0
        public void LoginTest()
        {
            int systemId = 0;
            int userId = 0; 
            string userName = "";
            List<RoleInfo> roleList = null;
            UserInfoBll userInfo = new UserInfoBll();
            int rlt = userInfo.Login(Consts.ConstValue.SystemCode, "admin", "admin", out systemId, out userId, out userName, out roleList);

        }
        private void InitGridView()
        {
            string userIdOrUserName = txtUserName.Text.Trim();
            UserInfoBll userInfoBll = new UserInfoBll();

            DataSet ds= userInfoBll.GetUserList(userIdOrUserName, DepartmentId);

            gvUserList.DataSource = ds;
            gvUserList.DataBind();
        }
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            int userId = 0;
            int.TryParse(((System.Web.UI.WebControls.WebControl)sender).ToolTip, out userId);

            UserInfoBll userInfoBll = new UserInfoBll();

            userInfoBll.DeleteByUserId(userId);
            Page.RegisterClientScriptBlock("", "<script>alert('删除成功');</script>");
            InitGridView();
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            UserInfoBll userInfoBll = new UserInfoBll();

            string userIdOrUserName = txtUserName.Text.Trim();
            int deparemntId = Convert.ToInt32( ddlDepartment.SelectedValue);

            DataSet ds = userInfoBll.GetUserList(userIdOrUserName, deparemntId);

            gvUserList.DataSource = ds;
            gvUserList.DataBind();
        }
Example #37
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string userCode = "fanruiquan";// txtUserName.Text.Trim();
            string password = "******";// txtPassword.Text.Trim();

            UserInfoBll userBll = new UserInfoBll();

            UserInfo userInfo = userBll.GetUserByCode(userCode);

            PageBase pageBase = new PageBase();

            if(pageBase.Login(userInfo,password ))
            {
                Response.Redirect("Main.aspx");
            }
        }
Example #38
0
 private void bthlogin_Click(object sender, EventArgs e)
 {
     //登录
     if (CheakLoginNameAndPwd())
     {
      //都不为空
         UserInfoBll userBll = new UserInfoBll();
         LoginStatus result = userBll.GetUserInfoByLoginName(txtname.Text, txtpwd.Text);
         if (result == LoginStatus.LoginNameNotFound)
         {
             md.MsgDivShow("账号不存在", 1);
         }
         else if (result == LoginStatus.PasswordError)
         {
             md.MsgDivShow("密码错误了", 1);
         }
         else if (result == LoginStatus.OK)
         {
             md.MsgDivShow("登录成功", 1,Bind);
         }
     }
 }
        private void InitExistGridView()
        {
            RoleBll roleBll = new RoleBll();

            RoleInfo roleInfo = roleBll.GetRoleById(RoleId);

            if (roleInfo != null)
            {
                lblCurrentRoleName.Text = roleInfo.RoleName;
            }

            UserInfoBll userBll = new UserInfoBll();

            List<UserInfo> userList = userBll.GetUserListByRoleId(RoleId);

            if (userList.Count > 0)
            {
                gvExistsUserList.DataSource = userList;

                gvExistsUserList.DataBind();
            }
            else
            {
                BindNotRecord(gvExistsUserList);
            }
        }
Example #40
0
 /****** 获取用户关注、退出关注的信息model **************/
 private bool IsExistUser()
 {
     UserInfo user = new UserInfo();
     var root = doc.DocumentElement;
     user.openid = root.SelectSingleNode("FromUserName").InnerText;
     UserInfoBll userBll = new UserInfoBll();
     return userBll.IsExist(user);
 }
        private void InitData()
        {
            ProjectBll projectBll = new ProjectBll();

            ProjectInfo projectInfo = projectBll.GetProjectById(ProjectId);

            if(projectInfo!=null &&projectInfo.ProjectId>0)
            {
                txtProjectName.Text = projectInfo.ProjectName;

                ddlCustomerList.SelectedValue = projectInfo.CustomerId.ToString();

                UserInfoBll userInfoBll = new UserInfoBll();

                UserInfo userInfo = userInfoBll.GetUserListById(projectInfo.BussinessUserId);

                if(userInfo != null)
                {
                    lblBusinessName.Text = userInfo.UserName;
                    hidUserId.Value = userInfo.UserId.ToString();
                }
            }
        }
Example #42
0
        /// <summary>
        /// 取消关注的方法
        /// </summary>
        private void UnSubscribe()
        {
            UserInOrOut userInorOutModel = GetUserOutModel();

            UserInfo user = new UserInfo();
            user.openid = userInorOutModel.userId;

            UserInfoBll userBll = new UserInfoBll();
            DataTable userTable = userBll.GetUserTable(user);

            userInorOutModel.userName = userTable.Rows[0]["nickname"].ToString();
            userInorOutModel.groupID = userTable.Rows[0]["groupId"].ToString();
            userInorOutModel.groupName = userTable.Rows[0]["groupName"].ToString();
            UserInOrOutBll userInOrOutBll = new UserInOrOutBll();
            userInOrOutBll.Add(userInorOutModel);

            user = new UserInfo();
            user.openid = userInorOutModel.userId;
            userBll.Del(user);
        }
        private void InitNotExistUserGridView()
        {
            UserInfoBll userBll = new UserInfoBll();
            List<UserInfo> userList = userBll.GetNotUserListByRoleId(RoleId,txtUserIdOrName.Text.Trim(),txtDepartment.Text.Trim());

            if (userList.Count > 0)
            {
                gvNotExistsUserList.DataSource = userList;

                gvNotExistsUserList.DataBind();
            }
            else
            {
                BindNotRecord(gvNotExistsUserList);
            }
        }
Example #44
0
 public void Dispose()
 {
     this._DataDictionaryBll = null;
     this._EmployeeBll = null;
     this._IPBlacklistBll = null;
     this._MenuInfoBll = null;
     this._OrganizationBll = null;
     this._PurviewInfoBll = null;
     this._RoleInfoBll = null;
     this._RolePurviewBll = null;
     this._SysLogBll = null;
     this._SysLoginLogBll = null;
     this._SystemExceptionLogBll = null;
     this._SystemInfoBll = null;
     this._UserInfoBll = null;
     this._UserPurviewBll = null;
     this._UserRoleBll = null;
 }
Example #45
0
        /**********  事件处理方法 **************/
        /// <summary>
        /// 关注时候的操作
        /// </summary>
        private void Subscribe()
        {
            if (IsExistUser())
                return;
            UserInOrOut userInorOutModel = GetUserInModel();

            UserInfoBll userBll = new UserInfoBll();
            UserInfo user = userBll.GetUserInfo(userInorOutModel.userId);
            userInorOutModel.userName = user.nickname;

            UserInOrOutBll userInOrOutBll = new UserInOrOutBll();
            userInOrOutBll.Add(userInorOutModel);

            user = new UserInfo();
            user = userBll.GetUserInfo(userInorOutModel.userId);
            userBll.Add(user);
        }
        private void InitData()
        {
            UserInfoBll userInfoBll = new UserInfoBll();
            UserInfo userInfo = userInfoBll.GetUserListById(UserId);

            if(userInfo!=null)
            {
                txtUserID.Text = userInfo.UserCode;
                txtUserName.Text = userInfo.UserName;
                txtTle.Text = userInfo.TelPhone;
                txtMoblie.Text = userInfo.MobilePhone;
                txtMail.Text = userInfo.EMail;
            }
        }