示例#1
0
        /// <summary>
        /// 优惠劵列表
        /// </summary>
        /// <param name="sn">编号</param>
        /// <param name="couponTypeId">优惠劵类型id</param>
        /// <param name="pageNumber">当前页数</param>
        /// <param name="pageSize">每页数</param>
        /// <returns></returns>
        public ActionResult CouponList(string sn, string accountName, int couponTypeId = -1, int pageNumber = 1, int pageSize = 15)
        {
            CouponTypeInfo couponTypeInfo = AdminCoupons.AdminGetCouponTypeById(couponTypeId);

            if (couponTypeInfo == null)
            {
                return(PromptView("优惠劵类型不存在"));
            }
            if (couponTypeInfo.StoreId != WorkContext.StoreId)
            {
                return(PromptView("不能操作其它店铺的优惠劵类型"));
            }

            int uid = AdminUsers.GetUidByAccountName(accountName);

            string condition = AdminCoupons.AdminGetCouponListCondition(sn, uid, couponTypeId);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminCoupons.AdminGetCouponCount(condition));

            CouponListModel model = new CouponListModel()
            {
                PageModel    = pageModel,
                CouponList   = AdminCoupons.AdminGetCouponList(pageModel.PageSize, pageModel.PageNumber, condition),
                AccountName  = accountName,
                CouponTypeId = couponTypeId,
                SN           = sn
            };

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&couponTypeId={3}&sn={4}&accountName={5}",
                                                          Url.Action("couponlist"),
                                                          pageModel.PageNumber, pageModel.PageSize,
                                                          couponTypeId, sn, accountName));
            return(View(model));
        }
示例#2
0
        public async Task <IActionResult> login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                AdminUsers user = await _dapper.FindByLoginAsync(model.UserName, model.Password);

                if (user != null)
                {
                    AuthenticationProperties props = new AuthenticationProperties
                    {
                        IsPersistent = true,
                        ExpiresUtc   = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(1)),
                        AllowRefresh = true
                    };
                    //var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
                    //                identity.AddClaim(new Claim(ClaimTypes.Sid, userName));
                    //                identity.AddClaim(new Claim(ClaimTypes.Name, user.Name));
                    //                 identity.AddClaim(new Claim(ClaimTypes.Role, user.Role));

                    //var Claims = new List<Claim>() { new Claim(JwtClaimTypes.Role, "admin") };
                    await HttpContext.SignInAsync(user.Id.ToString(), user.LoginName, props, new Claim(JwtClaimTypes.Role, "admin"));

                    return(Redirect(model.ReturnUrl ?? "/"));
                }
                else
                {
                    View(model.ReturnUrl);
                }
            }
            return(View(model.ReturnUrl));
        }
示例#3
0
        public async Task <bool> AddAsync(AdminUsers admin)
        {
            _adminUsersRepository.Addasync(admin);
            var result = await _unitOfWork.SaveChangesAsync();

            return(result > 0);
        }
示例#4
0
        // Admin Users
        public bool AuthenticateAdminUser(string email, string password, ref string errorMessage)
        {
            bool result = false;

            try
            {
                UserAccount u = AdminUsers.FindByEmail(email);
                if (u == null)
                {
                    errorMessage = "Please check your email address and password and try again.";
                    return(false);
                }

                if (!u.DoesPasswordMatch(password))
                {
                    errorMessage = "Please check your email address and password and try again.";
                    return(false);
                }

                if (u.Status == UserAccountStatus.Disabled)
                {
                    errorMessage = "Your account is not currently active. Please contact an administrator for details.";
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                result = false;
                EventLog.LogEvent(ex);
                errorMessage = "Unknown login error. Contact administrator for assistance.";
            }
            return(result);
        }
示例#5
0
        public ActionResult Edit(int uid = -1)
        {
            UserInfo userInfo = AdminUsers.GetUserById(uid);

            if (userInfo == null)
            {
                return(PromptView("用户不存在"));
            }

            UserModel model = new UserModel();

            model.UserName   = userInfo.UserName;
            model.Email      = userInfo.Email;
            model.Mobile     = userInfo.Mobile;
            model.UserRid    = userInfo.UserRid;
            model.AdminGid   = userInfo.AdminGid;
            model.NickName   = userInfo.NickName;
            model.Avatar     = userInfo.Avatar;
            model.PayCredits = userInfo.PayCredits;
            model.Gender     = userInfo.Gender;
            model.RealName   = userInfo.RealName;
            model.Bday       = userInfo.Bday;
            model.IdCard     = userInfo.IdCard;
            model.RegionId   = userInfo.RegionId;
            model.Address    = userInfo.Address;
            model.Bio        = userInfo.Bio;

            Load(model.RegionId);

            return(View(model));
        }
示例#6
0
        public async Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
        {
            //根据context.UserName和context.Password与数据库的数据做校验,判断是否合法
            if (!string.IsNullOrWhiteSpace(context.UserName) && !string.IsNullOrWhiteSpace(context.Password))
            {
                AdminUsers user = await _adminUsers.FindByLoginAsync(context.UserName, context.Password);

                if (user != null)
                {
                    context.Result = new GrantValidationResult(
                        subject: context.UserName,
                        authenticationMethod: "custom",
                        claims: new Claim[] { new Claim(JwtClaimTypes.Role, "admin") },
                        authTime: DateTime.Now.AddDays(1)
                        );
                }
                else
                {
                    context.Result = new GrantValidationResult(TokenRequestErrors.InvalidRequest, "invalid custom credential");
                }
            }
            else
            {
                //验证失败
                context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant, "invalid custom credential");
            }
        }
示例#7
0
        public JsonResult GetCompanyManager(string sidx, string sort, int page, int rows)
        {
            sort = (sort == null) ? "" : sort;
            int        pageIndex     = Convert.ToInt32(page) - 1;
            int        pageSize      = rows;
            AdminUsers obj           = new AdminUsers();
            var        CompaniesList = obj.GetCompanyManager();
            int        totalRecords  = CompaniesList.Count();
            var        totalPages    = (int)Math.Ceiling((float)totalRecords / (float)rows);

            if (sort.ToUpper() == "DESC")
            {
                CompaniesList = CompaniesList.OrderByDescending(t => t.ServiceFirstCompanyManagerID).ToList();
                CompaniesList = CompaniesList.Skip(pageIndex * pageSize).Take(pageSize).ToList();
            }
            else
            {
                CompaniesList = CompaniesList.OrderBy(t => t.ServiceFirstCompanyManagerID).ToList();
                CompaniesList = CompaniesList.Skip(pageIndex * pageSize).Take(pageSize).ToList();
            }
            var jsonData = new
            {
                total = totalPages,
                page,
                records = totalRecords,
                rows    = CompaniesList
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
示例#8
0
        protected void btLogin_Click(object sender, EventArgs e)
        {
            string sUserID = txtMid.Text;
            string sPwd    = txtMpwd.Text;

            if (string.IsNullOrEmpty(sUserID) == false && string.IsNullOrEmpty(sPwd) == false)
            {
                DataTable users = AdminUsers.SearchAdminUser(sUserID, sPwd);

                if (users.Rows.Count > 0)
                {
                    Session["ADMIN_USERID"]    = users.Rows[0]["UserID"].ToString();
                    Session["ADMIN_USERLEVEL"] = users.Rows[0]["UserLevel"].ToString();


                    Response.Redirect("Default.aspx");
                }
                else
                {
                    //RegisterStartupScript("", "<script>alert(' Incorrect password or ID ')</script>");
                    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(' Incorrect password or ID ')</script>");
                }
            }
            else
            {
                //RegisterStartupScript("", "<script>alert(' Incorrect password or ID ')</script>");
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(' Incorrect password or ID ')</script>");
            }
        }
示例#9
0
        public ActionResult EditDraw(MD_DrawAccount model, int uid = -1)
        {
            UserInfo userInfo = AdminUsers.GetUserById(uid);

            if (userInfo == null)
            {
                return(PromptView("用户不存在"));
            }

            if (ModelState.IsValid)
            {
                model.Drawpwd = Users.CreateUserPassword(model.Drawpwd, userInfo.Salt);
                model.Account = userInfo.Mobile;
                bool result = false;

                result = Recharge.UpdateDrawPWD(model);
                if (result)
                {
                    return(PromptView("提现密码修改成功"));
                }
                else
                {
                    return(PromptView("提现密码修改失败"));
                }
            }
            Load(0);

            return(View(model));
        }
示例#10
0
        public ActionResult ActiveCompany(int?Id)
        {
            AdminUsers obj = new AdminUsers();

            obj.ActiveCompany(Id);
            return(RedirectToAction("CompanyList", "Admin"));
        }
示例#11
0
        public ActionResult InActiveCompanyManager(int?Id)
        {
            AdminUsers obj = new AdminUsers();

            obj.InActiveCompanyManager(Id);
            return(RedirectToAction("CompanyManagerList", "Admin"));
        }
示例#12
0
        public ActionResult Edit(int?id, [Bind(Include = "start,length,search,gId")] RouteValue routeValue)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            AdminUsers user = AdminUsers.Get(id.Value);

            if (user == null)
            {
                return(HttpNotFound());
            }

            Warehouses            = new GenericRepository <Warehouses>(db);
            ViewBag.warehouseList = Warehouses.GetAll(true).Where(w => w.IsEnable == true && w.IsSellable == true).ToList();
            ViewBag.timeZoneList  = new Dictionary <EnumData.TimeZone, string>()
            {
                { EnumData.TimeZone.EST, "Eastern Standard Time" }, { EnumData.TimeZone.TST, "Taipei Standard Time" }, { EnumData.TimeZone.PST, "Pacific Standard Time" },
                { EnumData.TimeZone.GMT, "Greenwich Mean Time" }, { EnumData.TimeZone.AEST, "AUS Eastern Standard Time" }, { EnumData.TimeZone.JST, "Tokyo Standard Time" }
            };

            IEnumerable <AdminGroups> groupList = AdminGroups.GetAll(true).Where(g => g.IsEnable && g.IsVisible).OrderBy(g => g.Order);

            ViewData["groupList"] = new SelectList(groupList, "Id", "name", user.GroupId);

            ViewBag.routeValue = routeValue;
            return(View("~/Views/admin/users/edit.cshtml", user));
        }
示例#13
0
        public bool IsTokenValidForSuperUser(Guid tokenId)
        {
            AuthToken t = AuthTokens.FindByTokenId(tokenId);

            if (t == null)
            {
                return(false);
            }
            if (t.Expires < DateTime.UtcNow)
            {
                return(false);
            }

            UserAccount u = AdminUsers.FindById(t.UserId);

            if (u == null)
            {
                return(false);
            }

            if (u.Status == UserAccountStatus.SuperUser)
            {
                return(true);
            }

            return(false);
        }
示例#14
0
        /// <summary>
        /// 管理员操作日志列表
        /// </summary>
        /// <param name="accountName">操作人</param>
        /// <param name="operation">操作动作</param>
        /// <param name="startTime">操作开始时间</param>
        /// <param name="endTime">操作结束时间</param>
        /// <param name="pageNumber">当前页数</param>
        /// <param name="pageSize">每页数</param>
        /// <returns></returns>
        public ActionResult AdminOperateLogList(string accountName, string operation, string startTime, string endTime, int pageNumber = 1, int pageSize = 15)
        {
            int uid = AdminUsers.GetUidByAccountName(accountName);

            string condition = AdminOperateLogs.GetAdminOperateLogListCondition(uid, operation, startTime, endTime);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminOperateLogs.GetAdminOperateLogCount(condition));

            AdminOperateLogListModel model = new AdminOperateLogListModel()
            {
                PageModel           = pageModel,
                AdminOperateLogList = AdminOperateLogs.GetAdminOperateLogList(pageModel.PageSize, pageModel.PageNumber, condition),
                AccountName         = accountName,
                Operation           = operation,
                StartTime           = startTime,
                EndTime             = endTime
            };

            ShopUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&accountName={3}&operation={4}&startTime={5}&endTime={6}",
                                                          Url.Action("adminoperateloglist"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize,
                                                          accountName, operation, startTime, endTime));
            return(View(model));
        }
示例#15
0
        public ActionResult UpdAccount(int id, decimal fee)
        {
            UserInfo userInfo = AdminUsers.GetUserById(id);

            if (userInfo == null)
            {
                return(AjaxResult("success", "用户不存在"));
            }
            var result = Users.UpdateUserAccount(id, fee);

            if (result)
            {
                MD_Change achange = new MD_Change()
                {
                    Account     = userInfo.Mobile,
                    Accounted   = userInfo.TotalMoney,
                    Changemoney = fee,
                    Remark      = fee > 1?"上分":"下分"
                };
                var s = NewUser.AddAChange(achange);
                AddAdminOperateLog("修改用户账余", "修改用户账余,用户ID为:" + id);
                return(AjaxResult("success", "修改用户账余成功"));
            }
            else
            {
                return(AjaxResult("error", "用户账余修改失败"));
            }
        }
示例#16
0
        public ActionResult Edit(UserModel model, int uid = -1)
        {
            UserInfo userInfo = AdminUsers.GetUserById(uid);

            if (userInfo == null)
            {
                return(PromptView("用户不存在"));
            }


            int uid4 = AdminUsers.GetUidByMobile(model.Mobile);

            if (uid4 > 0 && uid4 != uid)
            {
                ModelState.AddModelError("Mobile", "手机号已经存在");
            }

            if (ModelState.IsValid)
            {
                string nickName;
                if (string.IsNullOrWhiteSpace(model.NickName))
                {
                    nickName = userInfo.NickName;
                }
                else
                {
                    nickName = model.NickName;
                }

                userInfo.UserName = model.Mobile;
                userInfo.Mobile   = model.Mobile;
                if (!string.IsNullOrWhiteSpace(model.Password))
                {
                    userInfo.Password = Users.CreateUserPassword(model.Password, userInfo.Salt);
                }
                userInfo.UserRid  = model.UserRid == 0 ? 7 : model.UserRid;
                userInfo.NickName = WebHelper.HtmlEncode(nickName);

                userInfo.AdminGid = model.AdminGid;
                bool result = false;


                result = AdminUsers.UpdateUser(userInfo);
                if (result)
                {
                    AddAdminOperateLog("修改用户", "修改用户,用户ID为:" + uid);
                    return(PromptView("用户修改成功"));
                }
                else
                {
                    return(PromptView("用户修改失败"));
                }
            }

            Load(model.RegionId);

            return(View(model));
        }
示例#17
0
        /// <summary>
        /// 用户列表
        /// </summary>
        private ActionResult List(string userName, string email, string mobile, int userRid = 0, int adminGid = 0, int pageNumber = 1, int pageSize = 15)
        {
            string condition = AdminUsers.AdminGetUserListCondition(userName, email, mobile, userRid, adminGid);
            //管理员可以在后台修改自己的密码
            //if (condition != "")
            //    condition += " and owzx_users.uid<>" + WorkContext.Uid;
            //else
            //    condition = " owzx_users.uid<>" + WorkContext.Uid;

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminUsers.AdminGetUserCount(condition));

            List <SelectListItem> userRankList = new List <SelectListItem>();

            userRankList.Add(new SelectListItem()
            {
                Text = "全部等级", Value = "0"
            });
            foreach (UserRankInfo info in AdminUserRanks.GetUserRankList())
            {
                userRankList.Add(new SelectListItem()
                {
                    Text = info.Title, Value = info.UserRid.ToString()
                });
            }

            List <SelectListItem> adminGroupList = new List <SelectListItem>();

            adminGroupList.Add(new SelectListItem()
            {
                Text = "全部组", Value = "0"
            });
            foreach (AdminGroupInfo info in AdminGroups.GetAdminGroupList())
            {
                adminGroupList.Add(new SelectListItem()
                {
                    Text = info.Title, Value = info.AdminGid.ToString()
                });
            }

            UserListModel model = new UserListModel()
            {
                PageModel      = pageModel,
                UserList       = AdminUsers.AdminGetUserList(pageModel.PageSize, pageModel.PageNumber, condition),
                UserName       = userName,
                Email          = email,
                Mobile         = mobile,
                UserRid        = userRid,
                UserRankList   = userRankList,
                AdminGid       = adminGid,
                AdminGroupList = adminGroupList
            };

            ShopUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&userName={3}&email={4}&mobile={5}&userRid={6}&adminGid={7}",
                                                          Url.Action("list"), pageModel.PageNumber, pageModel.PageSize,
                                                          userName, email, mobile, userRid, adminGid));
            return(View(model));
        }
示例#18
0
        /// <summary>从门户后台管理自动登录</summary>
        private bool AutoLogin(string returnUrl)
        {
            var token = this.Request.QueryString["token"];

            if (token.IsNullOrEmpty())
            {
                return(false);
            }
            var userId = this.Context.GetPortalMgmtUserId(token);

            if (userId.IsNullOrEmpty())
            {
                return(false);
            }
            var nUserId = 0;

            if (!int.TryParse(userId, out nUserId))
            {
                return(false);
            }
            var user = this.Context.GetPortalMgmtUser(nUserId);

            if (user == null)
            {
                return(false);
            }
            var admin   = Users.GetUserInfo(user.USERNAME);
            var context = this.Context.GetHttpContextWrapper();
            var config  = GeneralConfigs.GetConfig();

            if (admin == null)
            {
                var principal = new PKSPrincipal();
                var identity  = new PKSIdentity();
                identity.Name        = user.USERNAME;
                identity.Email       = user.EMAIL;
                identity.PhoneNumber = user.PHONENUMBER;
                principal.Identity   = identity;
                admin = context.CreateUser(config, principal, true);
            }
            else if (admin.Adminid != 1 || admin.Groupid != 1)
            {
                admin.Adminid  = 1;
                admin.Groupid  = 1;
                admin.Authtime = Utils.GetDateTime();
                AdminUsers.UpdateUserAllInfo(admin);
                //移除该用户的在线信息,使之重建在线表信息
                OnlineUsers.DeleteUserByUid(admin.Uid);
            }
            var adminGroup = AdminUserGroups.AdminGetUserGroupInfo(admin.Groupid);

            ForumUtils.WriteUserCookie(admin.Uid, ForumExtension.ExpireMinutes, config.Passwordkey);
            this.Context.AddAdminCookie(config, admin.Uid, admin.Password, admin.Secques, ForumExtension.ExpireMinutes);
            SoftInfo.LoadSoftInfo();
            AdminVistLogs.InsertLog(admin.Uid, admin.Username, admin.Groupid, adminGroup.Grouptitle, DNTRequest.GetIP(), "后台管理员登陆", "");
            return(true);
        }
示例#19
0
        public async Task <DatabaseResponse> CreateAdminUser(RegisterAdminUser adminuser, int AdminUserID)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@FullName",  SqlDbType.NVarChar),
                    new SqlParameter("@Email",     SqlDbType.NVarChar),
                    new SqlParameter("@Password",  SqlDbType.NVarChar),
                    new SqlParameter("@RoleID",    SqlDbType.Int),
                    new SqlParameter("@CreatedBy", SqlDbType.Int)
                };

                parameters[0].Value = adminuser.FullName;
                parameters[1].Value = adminuser.Email;
                parameters[2].Value = new Sha2().Hash(adminuser.Password);
                parameters[3].Value = adminuser.RoleID;
                parameters[4].Value = AdminUserID;

                _DataHelper = new DataAccessHelper("Admin_CreateAdminUser", parameters, _configuration);

                DataTable dt = new DataTable();

                int result = await _DataHelper.RunAsync(dt);

                AdminUsers newCustomer = new AdminUsers();

                if (dt != null && dt.Rows.Count > 0)
                {
                    newCustomer = (from model in dt.AsEnumerable()
                                   select new AdminUsers()
                    {
                        AdminUserID = model.Field <int>("AdminUserID"),
                        Email = model.Field <string>("Email"),
                        Password = model.Field <string>("Password"),
                        Name = model.Field <string>("Name"),
                        Role = model.Field <string>("Role"),
                    }).FirstOrDefault();
                }

                return(new DatabaseResponse {
                    ResponseCode = result, Results = adminuser
                });
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
示例#20
0
 public ActionResult Users(AdminUsers data)
 {
     foreach (var u in data.Users)
     {
         _context.Entry(u).State = EntityState.Modified;
     }
     _context.SaveChanges();
     ViewBag.Roles = _context.Roles.ToList();
     return(View(data));
 }
示例#21
0
        public ActionResult AddUsers(Users users)
        {
            AdminUsers adminUsers = new AdminUsers();
            var        serializer = new JavaScriptSerializer();
            var        answer     = new ContentResult();

            answer.ContentType = "application/json";
            answer.Content     = serializer.Serialize(adminUsers.addUsers(users));
            return(answer);
        }
示例#22
0
        public UserAccount FindAdminUserByAuthTokenId(Guid tokenId)
        {
            AuthToken t = AuthTokens.FindByTokenId(tokenId);

            if (t == null)
            {
                return(null);
            }

            return(AdminUsers.FindById(t.UserId));
        }
示例#23
0
        public static void AdminChoiceOfMenu(int input, int adminId)
        {
            switch (input)
            {
            case 1:
                AdminBook.AddsBook(adminId);
                break;

            case 2:
                AdminBook.SetsAmount(adminId);
                break;

            case 3:
                AdminUsers.PrintUsers(adminId);
                break;

            case 4:
                AdminUsers.SearchForUser(adminId);
                break;

            case 5:
                AdminBook.UpdatesBook(adminId);
                break;

            case 6:
                AdminBook.DeleteBook(adminId);
                break;

            case 7:
                AdminBookCategory.AddsCategory(adminId);
                break;

            case 8:

                AdminBook.AddCategoryToBook(adminId);
                break;

            case 9:
                AdminBookCategory.UpdateCategory(adminId);
                break;

            case 10:
                AdminBookCategory.DeleteCategory(adminId);
                break;

            case 11:
                AdminUsers.AddingUser(adminId);
                break;

            default:
                Messages.WrongInput();
                break;
            }
        }
示例#24
0
        public ActionResult Users()
        {
            var users = _context.Users.ToList();

            @ViewBag.Roles = _context.Roles.ToList();
            var data = new AdminUsers
            {
                Users = users
            };

            return(View(data));
        }
示例#25
0
        public ActionResult AutenticateUser(Users users)
        {
            AdminUsers adminUsers = new AdminUsers();
            var        serializer = new JavaScriptSerializer();
            var        answer     = new ContentResult();

            answer.ContentType = "application/json";
            var token = adminUsers.getUsers(users);

            answer.Content = serializer.Serialize(new { token = token });
            return(answer);
        }
示例#26
0
 /// <summary>
 /// 创建订单行为
 /// </summary>
 private void CreateOrderAction(int oid, OrderActionType orderActionType, string actionDes)
 {
     OrderActions.CreateOrderAction(new OrderActionInfo()
     {
         Oid        = oid,
         Uid        = WorkContext.Uid,
         RealName   = AdminUsers.GetUserDetailById(WorkContext.Uid).RealName,
         ActionType = (int)orderActionType,
         ActionTime = DateTime.Now,
         ActionDes  = actionDes
     });
 }
示例#27
0
        /// <summary>
        /// 用户列表
        /// </summary>
        public ActionResult List(string userName, string email, string mobile, int userRid = 0, int adminGid = 0,
                                 int pageNumber = 1, int pageSize = 15)
        {
            string condition = AdminUsers.AdminGetUserListCondition(userName, email, mobile, userRid, adminGid);
            string sort      = AdminUsers.AdminGetUserListSort("", "");

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminUsers.AdminGetUserCount(condition));

            UserListModel model = new UserListModel()
            {
                UserList  = AdminUsers.AdminGetUserList(pageModel.PageSize, pageModel.PageNumber, condition, sort),
                PageModel = pageModel,
                UserName  = userName,
                Email     = email,
                Mobile    = mobile,
                UserRid   = userRid,
                AdminGid  = adminGid
            };
            List <SelectListItem> userRankList = new List <SelectListItem>();

            userRankList.Add(new SelectListItem()
            {
                Text = "全部等级", Value = "0"
            });
            foreach (UserRankInfo info in AdminUserRanks.GetUserRankList())
            {
                userRankList.Add(new SelectListItem()
                {
                    Text = info.Title, Value = info.UserRid.ToString()
                });
            }
            ViewData["userRankList"] = userRankList;

            List <SelectListItem> adminGroupList = new List <SelectListItem>();

            adminGroupList.Add(new SelectListItem()
            {
                Text = "全部组", Value = "0"
            });
            foreach (AdminGroupInfo info in AdminGroups.GetAdminGroupList())
            {
                adminGroupList.Add(new SelectListItem()
                {
                    Text = info.Title, Value = info.AdminGid.ToString()
                });
            }
            ViewData["adminGroupList"] = adminGroupList;

            ShopUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&userName={3}&email={4}&mobile={5}&userRid={6}&adminGid={7}",
                                                          Url.Action("list"), pageModel.PageNumber, pageModel.PageSize,
                                                          userName, email, mobile, userRid, adminGid));
            return(View(model));
        }
        private void DelUserInfo_Click(object sender, EventArgs e)
        {
            #region  除指定用户信息

            if (this.CheckCookie())
            {
                int uid = DNTRequest.GetInt("uid", -1);

                if (!AllowEditUserInfo(uid, true))
                {
                    return;
                }

                if (AllowDeleteUser(this.userid, uid))
                {
                    bool delpost = !(deltype.SelectedValue.IndexOf("1") >= 0);
                    bool delpms  = !(deltype.SelectedValue.IndexOf("2") >= 0);

                    if (SpacePluginProvider.GetInstance() != null)
                    {
                        SpacePluginProvider.GetInstance().Delete(uid);
                    }

                    if (AlbumPluginProvider.GetInstance() != null)
                    {
                        AlbumPluginProvider.GetInstance().Delete(uid);
                    }
                    if (AdminUsers.DelUserAllInf(uid, delpost, delpms))
                    {
                        //删除用户同步
                        Discuz.Forum.Sync.DeleteUsers(uid.ToString(), "");
                        //ManyouApplications.AddUserLog(uid, UserLogActionEnum.Delete);
                        //删除该用户头像
                        Avatars.DeleteAvatar(uid.ToString());
                        AdminUsers.UpdateForumsFieldModerators(userName.Text);

                        OnlineUsers.DeleteUserByUid(userInfo.Uid);    //移除该用户的在线信息,使之退出
                        AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台删除用户", "用户名:" + userName.Text);
                        base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';");
                    }
                    else
                    {
                        base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';</script>");
                    }
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败,你要删除的用户是创始人用户或是其它管理员,因此不能删除!');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';</script>");
                }
            }

            #endregion
        }
示例#29
0
        /// <summary>
        /// 用户列表
        /// </summary>
        public ActionResult List(string userName, string email, string mobile, int userRid = 0, int mallAGid = 0, int pageNumber = 1, int pageSize = 15)
        {
            string condition = AdminUsers.AdminGetUserListCondition(userName, email, mobile, userRid, mallAGid);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminUsers.AdminGetUserCount(condition));

            List <SelectListItem> userRankList = new List <SelectListItem>();

            userRankList.Add(new SelectListItem()
            {
                Text = "全部等级", Value = "0"
            });
            foreach (UserRankInfo info in AdminUserRanks.GetUserRankList())
            {
                userRankList.Add(new SelectListItem()
                {
                    Text = info.Title, Value = info.UserRid.ToString()
                });
            }

            List <SelectListItem> mallAdminGroupList = new List <SelectListItem>();

            mallAdminGroupList.Add(new SelectListItem()
            {
                Text = "全部组", Value = "0"
            });
            foreach (MallAdminGroupInfo info in MallAdminGroups.GetMallAdminGroupList())
            {
                mallAdminGroupList.Add(new SelectListItem()
                {
                    Text = info.Title, Value = info.MallAGid.ToString()
                });
            }

            UserListModel model = new UserListModel()
            {
                PageModel          = pageModel,
                UserList           = AdminUsers.AdminGetUserList(pageModel.PageSize, pageModel.PageNumber, condition),
                UserName           = userName,
                Email              = email,
                Mobile             = mobile,
                UserRid            = userRid,
                UserRankList       = userRankList,
                MallAGid           = mallAGid,
                MallAdminGroupList = mallAdminGroupList
            };

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&userName={3}&email={4}&mobile={5}&userRid={6}&mallAGid={7}",
                                                          Url.Action("list"), pageModel.PageNumber, pageModel.PageSize,
                                                          userName, email, mobile, userRid, mallAGid));
            return(View(model));
        }
        // Admin Users
        public virtual List <UserAccount> FindAdminUsersByStoreId(long storeId)
        {
            var result = new List <UserAccount>();

            var relationships = AdminUsersXStores.FindByStoreId(storeId);

            foreach (var rel in relationships)
            {
                result.Add(AdminUsers.FindById(rel.UserId));
            }

            return(result);
        }