예제 #1
0
        public ActionResult ResetPassword(int?id)
        {
            JsonModel jm = new JsonModel();

            //参数校验
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            // 根据指定id值获取实体对象
            var userInfo = platformUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (userInfo != null)
            {
                Random r      = new Random();
                int    radVal = r.Next(100, 1000);
                userInfo.Password = PropertyUtils.GetMD5Str(userInfo.UserName + radVal);
                // 恢复初始密码值
                platformUserBll.Update(userInfo);

                // 给用户发送邮件
                PropertyUtils.SendEmail(userInfo.Email, userInfo.UserName, "物业生活管理系统 用户密码重置", "您的用户密码已重置为" + userInfo.UserName + radVal + ", 请及时修改密码!");
                //操作日志
                jm.Content = "平台用户" + userInfo.TrueName + "密码一键重置成功";
            }
            else
            {
                jm.Msg = "该用户不存在";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult ScanRole(int id)
        {
            // 创建平台用户角色模型
            PlatformUserRoleModel userRoleModel = new PlatformUserRoleModel();

            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            // 根据指定id值获取实体对象
            var userInfo = platformUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            userRoleModel.User = new PlatformUserModel()
            {
                UserName = userInfo.UserName,
                UserId   = userInfo.Id,
                TrueName = userInfo.TrueName
            };

            // 获取用户已分配的角色id列表
            var selectedRoleList = userInfo.PlatformUserRoles.Select(m => m.RoleId).ToList();

            userRoleModel.RoleIds = selectedRoleList;

            // 获取所有平台角色
            IPlatformRoleBLL platformRoleBll = BLLFactory <IPlatformRoleBLL> .GetBLL("PlatformRoleBLL");

            //排序
            var sortModel = this.SettingSorting("Id", false);
            var roleList  = platformRoleBll.GetList(p => true, sortModel.SortName, sortModel.IsAsc).ToList();

            userRoleModel.RoleList = roleList;

            return(View(userRoleModel));
        }
예제 #3
0
        public ActionResult EditUser(int?id)
        {
            // 参数校验
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            var userInfo = platformUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (userInfo != null)
            {
                PlatformUserModel platformUserModel = new PlatformUserModel();
                platformUserModel.UserId   = userInfo.Id;
                platformUserModel.UserName = userInfo.UserName;
                platformUserModel.TrueName = userInfo.TrueName;
                platformUserModel.Memo     = userInfo.Memo;
                platformUserModel.Tel      = userInfo.Tel;
                platformUserModel.Phone    = userInfo.Phone;
                platformUserModel.Email    = userInfo.Email;
                platformUserModel.HeadPath = userInfo.HeadPath;
                return(View(platformUserModel));
            }
            else
            {
                return(RedirectToAction("UserList"));
            }
        }
예제 #4
0
        public ActionResult SetPlatUserInfo()
        {
            // 获取Session Model
            UserSessionModel model = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO];
            var id = model.UserID;

            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            var userInfo = platformUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (userInfo != null)
            {
                LoggedInAccountModel platformUserModel = new LoggedInAccountModel();
                platformUserModel.UserId   = userInfo.Id;
                platformUserModel.UserName = userInfo.UserName;
                platformUserModel.TrueName = userInfo.TrueName;
                platformUserModel.Memo     = userInfo.Memo;
                platformUserModel.Tel      = userInfo.Tel;
                platformUserModel.Phone    = userInfo.Phone;
                platformUserModel.Email    = userInfo.Email;
                platformUserModel.HeadPath = userInfo.HeadPath;
                return(View(platformUserModel));
            }
            else
            {
                return(RedirectToAction("Index", "Platform"));
            }
        }
예제 #5
0
        public ActionResult AddUser(PlatformUserModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

                T_PlatformUser platformUser = new T_PlatformUser()
                {
                    UserName = model.UserName,
                    TrueName = model.TrueName,
                    Password = PropertyUtils.GetMD5Str(model.Password),
                    Memo     = model.Memo,
                    Tel      = model.Tel,
                    Phone    = model.Phone,
                    Email    = model.Email
                };
                // 保存到数据库
                platformUserBll.Save(platformUser);

                //日志记录
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }

            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        public ActionResult EditPlatUserPwd(AccountPasswordChangeModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                UserSessionModel sessionModel = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO];
                var id = sessionModel.UserID;

                // 若当前登录用户为平台用户
                IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

                T_PlatformUser platformUser = platformUserBll.GetEntity(m => m.Id == model.UserId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (platformUser != null)
                {
                    platformUser.Password = PropertyUtils.GetMD5Str(model.Password);
                    // 保存到数据库
                    platformUserBll.Update(platformUser);

                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "该用户不存在";
                }
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        public ActionResult ConfigRole(int id)
        {
            // 创建平台用户角色模型
            PlatformUserRoleModel userRoleModel = new PlatformUserRoleModel();

            // 获取指定id的平台用户模型
            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            T_PlatformUser platformUser = platformUserBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            userRoleModel.User = new PlatformUserModel()
            {
                UserId   = platformUser.Id,
                UserName = platformUser.UserName,
                TrueName = platformUser.TrueName,
                Tel      = platformUser.Tel,
                Phone    = platformUser.Phone,
                Memo     = platformUser.Memo,
                Email    = platformUser.Email
            };

            // 获取所有平台角色
            IPlatformRoleBLL platformRoleBll = BLLFactory <IPlatformRoleBLL> .GetBLL("PlatformRoleBLL");

            //排序
            var sortModel = this.SettingSorting("Id", false);
            var roleList  = platformRoleBll.GetList(p => p.IsSystem == ConstantParam.USER_ROLE_DEFAULT, sortModel.SortName, sortModel.IsAsc).ToList();

            userRoleModel.RoleList = roleList;

            //获取该用户已分配的角色id的集合
            userRoleModel.RoleIds = platformUser.PlatformUserRoles.Select(m => m.RoleId).ToList();

            return(View(userRoleModel));
        }
예제 #8
0
        public ActionResult DeleteUser(int?id)
        {
            JsonModel jm = new JsonModel();

            //参数校验
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            // 根据指定id值获取实体对象
            var userInfo = platformUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (userInfo != null)
            {
                // 修改指定用户记录中的已删除标识
                userInfo.DelFlag = ConstantParam.DEL_FLAG_DELETE;
                platformUserBll.Update(userInfo);
                //操作日志
                jm.Content = "删除平台用户 " + userInfo.TrueName;
            }
            else
            {
                jm.Msg = "该用户不存在";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #9
0
        public ActionResult PlatformLogin(AccountModel model)
        {
            //判断提交模型数据是否正确
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            string code = (string)Session["ValidateCode"];

            if (model.CheckCode != code)
            {
                ModelState.AddModelError("CheckCode", "验证码不正确");
                return(View(model));
            }

            //根据用户名查找用户
            IPlatformUserBLL UserInfoBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            T_PlatformUser user = UserInfoBll.GetEntity(u => u.UserName == model.UserName.Trim() &&
                                                        u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //1.判断用户名是否正确
            if (user == null)
            {
                ModelState.AddModelError("UserName", "用户名不存在");
                return(View(model));
            }

            //2.判断密码是否正确
            string md5Str = PropertyUtils.GetMD5Str(model.Password);

            if (user.Password != md5Str)
            {
                ModelState.AddModelError("Password", "密码不正确");
                return(View(model));
            }
            //3.如果未设置角色
            if (user.PlatformUserRoles.Count == 0)
            {
                ModelState.AddModelError("UserName", "该用户未设置角色,请联系管理员");
                return(View(model));
            }

            //4.获取用户对象信息(拥有电站,权限菜单,Action等)保存基本信息到session中
            this.SetUserSessiong(user, UserInfoBll);

            //5.判断是否拥有访问首页的权限
            UserSessionModel session = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO];

            if (session.IsMgr == ConstantParam.USER_ROLE_DEFAULT && !session.ActionDic.ContainsKey("/Platform/Index"))
            {
                ModelState.AddModelError("UserName", "该用户无访问权限,请联系管理员");
                return(View(model));
            }
            BreadCrumb.ClearState();
            //6.跳转到
            return(RedirectToAction("Index", "Platform"));
        }
예제 #10
0
        public ActionResult UploadPic(string data, int userId)
        {
            JsonModel jm = new JsonModel();

            string directory = Server.MapPath(ConstantParam.PLATFORM_USER_HEAD_DIR);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }
            var fileName = DateTime.Now.ToFileTime().ToString() + ".jpg";
            var path     = Path.Combine(directory, fileName);

            using (FileStream fs = new FileStream(path, FileMode.Create))
            {
                using (BinaryWriter bw = new BinaryWriter(fs))
                {
                    byte[] datas = Convert.FromBase64String(data);
                    bw.Write(datas);
                    bw.Close();
                }
            }

            ////生成缩略图
            //string thumpFile = DateTime.Now.Millisecond + PSPlatformUtils.CreateValidateCode(4) + ".jpg";
            //var thumpPath = Path.Combine(Server.MapPath("~/Upload/User"), thumpFile);
            //PSPlatformUtils.getThumImage(path, 18, 3, thumpPath);

            IPlatformUserBLL UserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            var user = UserBll.GetEntity(m => m.DelFlag == 0 && m.Id == userId);

            //用户存在
            if (user != null)
            {
                string oldFile = user.HeadPath;
                user.HeadPath = ConstantParam.PLATFORM_USER_HEAD_DIR + fileName;
                UserBll.Update(user);
                //删除旧头像
                if (!string.IsNullOrEmpty(oldFile))
                {
                    oldFile = Server.MapPath(oldFile);
                    FileInfo f = new FileInfo(oldFile);
                    if (f.Exists)
                    {
                        f.Delete();
                    }
                }
            }
            //用户不存在
            else
            {
                jm.Msg = "用户不存在";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #11
0
        public ActionResult UserList(PlatformUserSearchModel model)
        {
            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            Expression <Func <T_PlatformUser, bool> > where = u => (string.IsNullOrEmpty(model.TrueName) ? true : u.TrueName.Contains(model.TrueName)) && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT;
            //排序模型
            var sortModel = this.SettingSorting("Id", false);
            var list      = platformUserBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex);

            return(View(list));
        }
예제 #12
0
        /// <summary>
        /// 远程验证指定平台用户名称是否存在
        /// </summary>
        /// <param name="UserName">平台用户名称</param>
        /// <param name="UserId">用户id,新增时恒为0,修改用户信息时不为0</param>
        public ContentResult RemoteCheckExist(int userId, string userName)
        {
            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            // 用户名已存在
            if (platformUserBll.Exist(m => m.UserName == userName && m.Id != userId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
            {
                // 校验不通过
                return(Content("false"));
            }
            else
            {
                return(Content("true"));
            }
        }
예제 #13
0
        public ActionResult SetPlatUserInfo(LoggedInAccountModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                // 获取Session Model
                UserSessionModel sessionModel = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO];
                var id = sessionModel.UserID;

                IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

                T_PlatformUser platformUser = platformUserBll.GetEntity(m => m.Id == model.UserId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (platformUser != null)
                {
                    platformUser.UserName = model.UserName;
                    platformUser.TrueName = model.TrueName;
                    platformUser.Memo     = model.Memo;
                    platformUser.Tel      = model.Tel;
                    platformUser.Phone    = model.Phone;
                    platformUser.Email    = model.Email;
                    // 保存到数据库
                    platformUserBll.Update(platformUser);

                    //更新SessionModel中的最新个人信息
                    sessionModel.TrueName = model.TrueName;

                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "该用户不存在";
                }
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #14
0
        public ActionResult EditPlatUserPwd()
        {
            UserSessionModel sessionModel = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO];
            var id = sessionModel.UserID;

            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            var userInfo = platformUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (userInfo != null)
            {
                AccountPasswordChangeModel platformUserModel = new AccountPasswordChangeModel();
                platformUserModel.UserId   = userInfo.Id;
                platformUserModel.UserName = userInfo.UserName;
                return(View(platformUserModel));
            }
            else
            {
                return(RedirectToAction("Index", "Platform"));
            }
        }
예제 #15
0
        /// <summary>
        /// 获取当前登录用户的头像图片路径
        /// </summary>
        /// <param name="html">HTML对象</param>
        /// <returns></returns>
        public static string GetLoginUserHeadImgPath(this HtmlHelper html)
        {
            //获取session对象
            var session = HttpContext.Current.Session;
            var model   = (UserSessionModel)session[ConstantParam.SESSION_USERINFO];

            if (model != null)
            {
                if (model.UserType == ConstantParam.USER_TYPE_PROPERTY)
                {
                    IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                    var user = userBll.GetEntity(u => u.Id == model.UserID);
                    return(user.HeadPath);
                }
                else if (model.UserType == ConstantParam.USER_TYPE_SHOP)
                {
                    IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                    var user = userBll.GetEntity(u => u.Id == model.UserID);
                    return(user.HeadPath);
                }
                else if (model.UserType == ConstantParam.USER_TYPE_PLATFORM)
                {
                    IPlatformUserBLL userBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

                    var user = userBll.GetEntity(u => u.Id == model.UserID);
                    return(user.HeadPath);
                }
                else if (model.UserType == ConstantParam.USER_TYPE_COMPANY)
                {
                    ICompanyUserBLL userBll = BLLFactory <ICompanyUserBLL> .GetBLL("CompanyUserBLL");

                    var user = userBll.GetEntity(u => u.Id == model.UserID);
                    return(user.HeadPath);
                }
            }
            return(null);
        }
예제 #16
0
        public ActionResult UploadPlatPic(int id)
        {
            JsonModel        jm      = new JsonModel();
            IPlatformUserBLL UserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            var user = UserBll.GetEntity(m => m.DelFlag == 0 && m.Id == id);

            //用户存在
            if (user != null)
            {
                LoggedInAccountModel userModel = new LoggedInAccountModel()
                {
                    UserId   = user.Id,
                    HeadPath = user.HeadPath
                };
                return(View(userModel));
            }
            //用户不存在
            else
            {
                jm.Msg = "用户不存在";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #17
0
        public ActionResult ConfigRole(UserConfigRoleModel model)
        {
            JsonModel jm = new JsonModel();

            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            //获取要分配角色的平台用户
            T_PlatformUser user = platformUserBll.GetEntity(m => m.Id == model.userId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            // 新建用户角色关联表
            List <R_PlatformUserRole> roles = new List <R_PlatformUserRole>();

            if (model.ids != null)
            {
                //没有设置任何角色 则不执行循环操作
                foreach (var id in model.ids)
                {
                    R_PlatformUserRole item = new R_PlatformUserRole()
                    {
                        UserId = model.userId, RoleId = id
                    };
                    roles.Add(item);
                }
            }

            //修改平台用户对应的角色集合
            if (platformUserBll.ConfigRole(user, roles))
            {
                jm.Content = "平台用户 " + user.TrueName + " 分配角色";
            }
            else
            {
                jm.Msg = "分配角色失败";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #18
0
        /// <summary>
        /// 保存用户的session信息
        /// </summary>
        /// <param name="user"></param>
        private void SetUserSessiong(T_PlatformUser user, IPlatformUserBLL bll)
        {
            //用户session模型
            UserSessionModel sessionInfo = new UserSessionModel();

            //设置基本信息
            sessionInfo.UserID   = user.Id;
            sessionInfo.UserName = user.UserName;
            sessionInfo.TrueName = user.TrueName;
            sessionInfo.IsMgr    = user.IsMgr;
            sessionInfo.UserType = ConstantParam.USER_TYPE_PLATFORM;
            sessionInfo.HeadPath = user.HeadPath;

            //构造菜单业务对象
            IMenuBLL menuBll = BLLFactory <IMenuBLL> .GetBLL("MenuBLL");


            #region 设置平台用户菜单以及权限
            //平台管理员
            if (user.IsMgr == ConstantParam.USER_ROLE_MGR)
            {
                //获取菜单
                var list = menuBll.GetList(m => m.MenuFlag == ConstantParam.MENU_LEFT &&
                                           m.IsPlatform == ConstantParam.USER_TYPE_PLATFORM).Select(m => new MenuModel
                {
                    MenuId     = m.Id,
                    MenuName   = m.MenuName,
                    MenuCode   = m.MenuCode,
                    MenuUrl    = m.Href,
                    MenuFlag   = m.MenuFlag,
                    MenuCss    = m.IconClass,
                    ParentId   = m.ParentId,
                    Order      = m.Order,
                    IsPlatform = m.IsPlatform
                }).ToList();

                //设置左边菜单
                sessionInfo.MenuList = list;
            }
            else
            {
                //获取平台用户对应的角色权限表
                var roleActions = user.PlatformUserRoles.Select(ur => ur.PlatformRole.PlatformRoleActions);

                //菜单字典
                Dictionary <string, MenuModel> menuDic   = new Dictionary <string, MenuModel>();
                Dictionary <string, string>    actionDic = new Dictionary <string, string>();

                foreach (var item in roleActions)
                {
                    var actions = item.Select(obj => obj.Action);
                    foreach (var action in actions)
                    {
                        //添加权限
                        if (!actionDic.ContainsKey(action.Href))
                        {
                            actionDic.Add(action.Href, action.ActionName);
                        }

                        foreach (var li in action.ActionItems)
                        {
                            //添加权限
                            if (!actionDic.ContainsKey(li.Href))
                            {
                                actionDic.Add(li.Href, li.ItemName);
                            }
                        }

                        var menu = action.Menu;
                        if (menu.ParentId != null)
                        {
                            if (!menuDic.ContainsKey(menu.ParentMenu.MenuCode))
                            {
                                menuDic.Add(menu.ParentMenu.MenuCode, GetMenuModel(menu.ParentMenu));
                            }
                        }
                        if (!menuDic.ContainsKey(menu.MenuCode))
                        {
                            menuDic.Add(menu.MenuCode, GetMenuModel(menu));
                        }
                    }
                }

                //设置菜单和权限
                sessionInfo.MenuList.AddRange(menuDic.Values.ToList());
                sessionInfo.ActionDic = actionDic;
            }
            #endregion

            //设置session信息
            Session[ConstantParam.SESSION_USERINFO] = sessionInfo;
        }
예제 #19
0
        public ActionResult Index(int id = 1)
        {
            PlatformIndexModel model = new PlatformIndexModel();

            #region 用户、公司、小区、业主个数统计

            //获取平台用户个数并赋值
            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            model.PlatformUserCount = platformUserBll.Count(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //获取物业公司个数并赋值
            IPropertyCompanyBLL companyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            model.CompanyCount = companyBll.Count(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //获取物业小区个数并赋值
            IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

            model.PlaceCount = placeBll.Count(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //获取业主个数并赋值
            IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            model.OwnerCount = ownerBll.Count(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //获取一周内登录个数
            DateTime beforeWeek = DateTime.Now.AddDays(-7);
            model.OwnerWeekLoginCount = ownerBll.Count(u => u.LatelyLoginTime >= beforeWeek);

            //获取一个月内登录个数
            DateTime beforeMonth = DateTime.Now.AddMonths(-1);
            model.OwnerMonthLoginCount = ownerBll.Count(u => u.LatelyLoginTime >= beforeMonth);

            #endregion

            #region 公司小区个数及业主个数统计(柱状图)

            //公司小区、业主个数模型集合
            var barDatas = new List <BarDataModel>();

            //获取物业公司名称及下辖小区个数及业主个数 数据并转换为Json字符串
            var companyList = companyBll.GetList(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT).ToList();
            foreach (var c in companyList)
            {
                BarDataModel data = new BarDataModel();
                //物业公司名称
                data.CompanyName = c.Name;
                var placeList = c.PropertyPlaces.Where(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //该物业公司的小区个数
                data.PlaceCount = placeList.Count();

                var userPlaces = new List <R_UserPlace>();
                //遍历物业小区
                foreach (var p in placeList)
                {
                    //遍历物业小区业主关联
                    foreach (var u in p.UserPlaces.ToList())
                    {
                        //如果不包含,则添加
                        if (!userPlaces.Contains(u))
                        {
                            userPlaces.Add(u);
                        }
                    }
                }
                //赋值 业主个数
                data.OwnerCount = userPlaces.Count;
                barDatas.Add(data);
            }
            model.BarJsonData = PropertyUtils.ModelToJsonString(barDatas);
            #endregion

            #region 小区业主列表数据
            //获取所有小区业主数据
            var list = placeBll.GetList(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT).ToList().Select(p => new OwnerDataModel()
            {
                PlaceName   = p.Name,
                CompanyName = p.Company.Name,
                OwnerCount  = p.UserPlaces.Count
            });
            //降序排序分页并赋值
            model.OwnerDatas = list.OrderByDescending(m => m.OwnerCount).ToPagedList(id, ConstantParam.PAGE_SIZE);
            #endregion

            return(View(model));
        }
예제 #20
0
        /// <summary>
        /// 获取当前登录用户的名字
        /// </summary>
        /// <param name="html">HTML对象</param>
        /// <returns></returns>
        public static string GetLoginUserName(this HtmlHelper html)
        {
            string name = "";
            //获取session对象
            var session = HttpContext.Current.Session;
            var model   = (UserSessionModel)session[ConstantParam.SESSION_USERINFO];

            if (model != null)
            {
                if (model.UserType == ConstantParam.USER_TYPE_PROPERTY)
                {
                    IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                    var user = propertyUserBll.GetEntity(u => u.Id == model.UserID);
                    if (!string.IsNullOrEmpty(user.TrueName))
                    {
                        name = user.TrueName;
                    }
                    else
                    {
                        name = user.UserName;
                    }
                }
                else if (model.UserType == ConstantParam.USER_TYPE_SHOP)
                {
                    IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                    var user = shopUserBll.GetEntity(u => u.Id == model.UserID);
                    if (!string.IsNullOrEmpty(user.TrueName))
                    {
                        name = user.TrueName;
                    }
                    else
                    {
                        name = user.UserName;
                    }
                }
                else if (model.UserType == ConstantParam.USER_TYPE_PLATFORM)
                {
                    IPlatformUserBLL userBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

                    var user = userBll.GetEntity(u => u.Id == model.UserID);
                    if (!string.IsNullOrEmpty(user.TrueName))
                    {
                        name = user.TrueName;
                    }
                    else
                    {
                        name = user.UserName;
                    }
                }
                else if (model.UserType == ConstantParam.USER_TYPE_COMPANY)
                {
                    ICompanyUserBLL userBll = BLLFactory <ICompanyUserBLL> .GetBLL("CompanyUserBLL");

                    var user = userBll.GetEntity(u => u.Id == model.UserID);
                    if (!string.IsNullOrEmpty(user.TrueName))
                    {
                        name = user.TrueName;
                    }
                    else
                    {
                        name = user.UserName;
                    }
                }
            }
            return(name);
        }