Exemplo n.º 1
0
        /// <summary>
        /// 删除指定物业用户
        /// </summary>
        /// <returns></returns>
        public ActionResult DeleteUser(int?id)
        {
            JsonModel jm = new JsonModel();

            //参数校验
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

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

            if (userInfo != null)
            {
                // 修改指定用户记录中的已删除标识
                userInfo.DelFlag = ConstantParam.DEL_FLAG_DELETE;
                propertyUserBll.Update(userInfo);
                //操作日志
                jm.Content = "删除物业用户 " + userInfo.TrueName;
            }
            else
            {
                jm.Msg = "该用户不存在";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult ResetPassword(int?id)
        {
            JsonModel jm = new JsonModel();

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

            // 根据指定id值获取实体对象
            var userInfo = propertyUserBll.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);
                // 恢复初始密码值
                propertyUserBll.Update(userInfo);

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

            IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

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

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

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

            userRoleModel.RoleIds = selectedRoleList;

            // 获取所有物业角色
            IPropertyRoleBLL propertyRoleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL");

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

            userRoleModel.RoleList = roleList;

            return(View(userRoleModel));
        }
Exemplo n.º 4
0
        public ActionResult AddUser(PropertyUserModel model)
        {
            JsonModel jm = new JsonModel();

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

                T_PropertyUser propertyUser = new T_PropertyUser()
                {
                    UserName        = model.UserName,
                    TrueName        = model.TrueName,
                    Password        = PropertyUtils.GetMD5Str(model.Password),
                    Memo            = model.Memo,
                    Tel             = model.Tel,
                    Phone           = model.Phone,
                    Email           = model.Email,
                    PropertyPlaceId = GetSessionModel().PropertyPlaceId.Value
                };
                // 保存到数据库
                propertyUserBll.Save(propertyUser);

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

            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 删除小区,删除其角色和用户
        /// </summary>
        /// <param name="place">小区实体对象</param>
        /// <returns></returns>
        public bool DeletePlace(T_PropertyPlace place)
        {
            //使用事务进行数据库操作
            using (var tran = this.nContext.Database.BeginTransaction())
            {
                try
                {
                    //修改用户为删除标识
                    IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                    var users = propertyUserBll.GetList(u => u.PropertyPlaceId == place.Id && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT).ToList();
                    foreach (var user in users)
                    {
                        user.DelFlag = ConstantParam.DEL_FLAG_DELETE;
                        propertyUserBll.Update(user);
                    }

                    //改为删除标识
                    base.Update(place);
                    //提交事务
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 6
0
        public ActionResult EditNews(CompanyNoticeModel model)
        {
            JsonModel jm = new JsonModel();

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

                T_CompanyPost newPost = postBll.GetEntity(m => m.Id == model.PostId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (newPost != null)
                {
                    newPost.Title         = model.Title;
                    newPost.Content       = model.Content;
                    newPost.PublishStatus = model.PublishedFlag ? 1 : 0;
                    newPost.IsOpen        = model.IsOpen ? 1 : 0;
                }
                ;
                if (model.PublishedFlag)
                {
                    newPost.PublishedTime = DateTime.Now;
                }
                // 保存到数据库,如果修改成功
                if (postBll.Update(newPost))
                {
                    //如果已发布并公开
                    if (model.PublishedFlag && model.IsOpen)
                    {
                        //推送给物业客户端
                        IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                        var PropertyUserIds = userBll.GetList(u => u.PropertyPlace.CompanyId == newPost.CompanyId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT).Select(u => u.Id);
                        if (PropertyUserIds != null)
                        {
                            PropertyUserIds = PropertyUserIds.ToList();
                        }
                        IPropertyUserPushBLL propertyUserPushBLL = BLLFactory <IPropertyUserPushBLL> .GetBLL("PropertyUserPushBLL");

                        var  propertyRegistrationIds = propertyUserPushBLL.GetList(p => PropertyUserIds.Contains(p.UserId)).Select(p => p.RegistrationId).ToArray();
                        bool flag = PropertyUtils.SendPush("总公司新闻公告", model.Title, ConstantParam.MOBILE_TYPE_PROPERTY, propertyRegistrationIds);
                        if (!flag)
                        {
                            jm.Msg = "推送发生异常";
                        }
                    }
                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "新闻公告编辑失败";
                }
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        public ActionResult PropertyLogin(AccountModel model)
        {
            //判断提交模型数据是否正确
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

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

            //根据用户名查找用户
            IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

            T_PropertyUser user = propertyUserBll.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.PropertyUserRoles.Count == 0)
            {
                ModelState.AddModelError("UserName", "该用户未设置角色,请联系管理员");
                return(View(model));
            }
            //4.获取用户对象信息(权限菜单,Action等)保存基本信息到session中
            this.SetUserSessiong(user, propertyUserBll);

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

            if (session.IsMgr == ConstantParam.USER_ROLE_DEFAULT && !session.ActionDic.ContainsKey("/Property/Index"))
            {
                ModelState.AddModelError("UserName", "该用户无访问权限,请联系管理员");
                return(View(model));
            }
            BreadCrumb.ClearState();
            //5.跳转到
            return(RedirectToAction("Index", "Property"));
        }
Exemplo n.º 8
0
        public ApiPageResultModel OwnInspectionExceptionList([FromUri] PagedSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    Expression <Func <T_InspectionResult, bool> > where = u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.InspectionTimePlan.InspectionPlan.PropertyPlaceId == user.PropertyPlaceId && u.Status == ConstantParam.EXCEPTION && u.DisposerId == user.Id;

                    //获取巡检异常总个数和分页数据
                    IInspectionResultBLL resultBll = BLLFactory <IInspectionResultBLL> .GetBLL("InspectionResultBLL");

                    resultModel.Total  = resultBll.Count(where);
                    resultModel.result = new
                    {
                        ExceptionList = resultBll.GetOwnInspectionResultPageList(where, model.PageIndex, ConstantParam.PAGE_SIZE).Select(r => new
                        {
                            Id            = r.Id,
                            PlanName      = r.InspectionTimePlan.InspectionPlan.PlanName,
                            PointName     = r.InspectionPoint.PointName,
                            Desc          = string.IsNullOrEmpty(r.Desc) ? "" : r.Desc,
                            DisposeStatus = r.DisposeStatus == null ? ConstantParam.NO_DISPOSE : r.DisposeStatus.Value,
                            UploadTime    = r.UploadTime.ToString("yyyy-MM-dd HH:mm:ss"),
                            Uploader      = r.UploadUser.UserName,
                            Imgs          = string.IsNullOrEmpty(r.Imgs) ? new string[] { } : r.Imgs.Split(';'),
                            DisposeDesc   = r.DisposeStatus == ConstantParam.DISPOSED ? r.ExceptionDisposes.FirstOrDefault().DisposeDesc : "",
                            DisposeTime   = r.DisposeStatus == ConstantParam.DISPOSED ? r.ExceptionDisposes.FirstOrDefault().DisposeTime.ToString("yyyy-MM-dd HH:mm:ss") : "",
                            DisposeUser   = r.DisposeStatus == ConstantParam.DISPOSED ? r.ExceptionDisposes.FirstOrDefault().DisposeUser.UserName : (r.DisposerId != null ? r.Disposer.UserName : "")
                        })
                    };
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 9
0
        public ApiResultModel GetVersionInfo([FromUri] TokenModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //获取当前用户
                IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //调用版本信息BLL层获取最新的版本信息
                    IMobileVersionBLL versionBll = BLLFactory <IMobileVersionBLL> .GetBLL("MobileVersionBLL");

                    var Versions = versionBll.GetList(v => v.Type == ConstantParam.MOBILE_TYPE_PROPERTY, "VersionCode", false);
                    //如果版本信息不为空
                    if (Versions != null && Versions.Count() > 0)
                    {
                        var highestVersion = Versions.First();
                        if (highestVersion != null)
                        {
                            resultModel.result = new
                            {
                                VersionCode = highestVersion.VersionCode,
                                VersionName = highestVersion.VersionName,
                                Desc        = highestVersion.Desc,
                                ApkFilePath = highestVersion.ApkFilePath
                            };
                        }
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.NO_APP;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 10
0
        public ApiResultModel DisposeException(DisposerModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //获取要处理的巡检异常
                    IInspectionResultBLL resultBll = BLLFactory <IInspectionResultBLL> .GetBLL("InspectionResultBLL");

                    T_InspectionResult result = resultBll.GetEntity(m => m.Id == model.Id);
                    if (result != null)
                    {
                        //修改处理状态并添加处理记录
                        result.DisposeStatus = ConstantParam.DISPOSED;
                        T_InspectionExceptionDispose exceptionDispose = new T_InspectionExceptionDispose()
                        {
                            DisposeDesc       = model.DisposeDesc,
                            DisposeUserId     = user.Id,
                            ExceptionResultId = model.Id,
                            DisposeTime       = DateTime.Now
                        };
                        //保存到数据库
                        resultBll.DisposeException(result, exceptionDispose);
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.EXCEPTION_NOEXIST;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 11
0
        public ActionResult UploadPic(string data, int userId)
        {
            JsonModel jm = new JsonModel();

            string directory = Server.MapPath(ConstantParam.PROPERTY_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);

            IPropertyUserBLL UserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

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

            //用户存在
            if (user != null)
            {
                string oldFile = user.HeadPath;
                user.HeadPath = ConstantParam.PROPERTY_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));
        }
Exemplo n.º 12
0
        public ApiPageResultModel PropertyNewsList([FromUri] PagedSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找物业用户
                IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser propertyUser = propertyUserBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果物业用户存在
                if (propertyUser != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > propertyUser.TokenInvalidTime || model.Token != propertyUser.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    propertyUser.LatelyLoginTime  = DateTime.Now;
                    propertyUser.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    propertyUserBll.Update(propertyUser);

                    // 获取指定物业小区id的公告列表
                    IPostBLL postBll = BLLFactory <IPostBLL> .GetBLL("PostBLL");

                    Expression <Func <T_Post, bool> > where = u => u.PropertyPlaceId == propertyUser.PropertyPlaceId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.PublishedFlag == ConstantParam.PUBLISHED_TRUE;
                    // TODO:此处Content不需要全部返回,待优化
                    var list = postBll.GetPageList(where, "PublishedTime", false, model.PageIndex).Select(s => new
                    {
                        ID           = s.Id,
                        propertyName = s.PropertyPlace.Name,
                        propertyPic  = string.IsNullOrEmpty(s.PropertyPlace.ImgThumbnail) ? "/Images/news_item_default.png" : s.PropertyPlace.ImgThumbnail,
                        pubDate      = s.PublishedTime.ToString(),
                        title        = s.Title,
                        content      = s.Content.Replace("\n", "")
                    }).ToList();
                    resultModel.result = list;
                    resultModel.Total  = postBll.GetList(where).Count();
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 13
0
        public ApiResultModel SetQuestionDisposer(SetDisposerModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //获取要指派处理人的问题
                    IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL");

                    T_Question question = questionBll.GetEntity(m => m.Id == model.Id);
                    if (question != null)
                    {
                        //指派处理人
                        question.DisposerId = model.DisposerId;
                        //保存到数据库
                        if (!questionBll.Update(question))
                        {
                            resultModel.Msg = APIMessage.SET_DISPOSER_FAIL;
                        }
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.QUESTION_NOEXIST;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 14
0
        public ApiPageResultModel CompanyNewsList([FromUri] PagedSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找物业用户
                IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser propertyUser = propertyUserBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果物业用户存在
                if (propertyUser != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > propertyUser.TokenInvalidTime || model.Token != propertyUser.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    propertyUser.LatelyLoginTime  = DateTime.Now;
                    propertyUser.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    propertyUserBll.Update(propertyUser);

                    //获取指定公司发布的公开新闻公告
                    ICompanyPostBLL postBll = BLLFactory <ICompanyPostBLL> .GetBLL("CompanyPostBLL");

                    Expression <Func <T_CompanyPost, bool> > where = u => u.CompanyId == propertyUser.PropertyPlace.CompanyId &&
                                                                     u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.PublishStatus == ConstantParam.PUBLISHED_TRUE && u.IsOpen == ConstantParam.PUBLISHED_TRUE;
                    var list = postBll.GetPageList(where, "PublishedTime", false, model.PageIndex).Select(s => new
                    {
                        ID            = s.Id,
                        CompanyName   = s.Company.Name,
                        CompanyIcon   = string.IsNullOrEmpty(s.Company.Img) ? "/Images/news_item_default.png" : s.Company.Img,
                        PublishedTime = s.PublishedTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
                        Title         = s.Title
                    }).ToList();
                    resultModel.result = list;
                    resultModel.Total  = postBll.Count(where);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 15
0
        public ActionResult UserList(SearchModel model)
        {
            IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

            int propertyPlaceId = GetSessionModel().PropertyPlaceId.Value;

            Expression <Func <T_PropertyUser, bool> > where = u => (string.IsNullOrEmpty(model.Kword) ? true : (u.TrueName.Contains(model.Kword) || u.UserName.Contains(model.Kword))) && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.PropertyPlaceId == propertyPlaceId;

            //排序
            var sortModel = this.SettingSorting("Id", false);
            var list      = propertyUserBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex);

            return(View(list));
        }
Exemplo n.º 16
0
        public ContentResult RemoteUserCheckExist(string userName)
        {
            IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

            // 用户名已存在
            if (propertyUserBll.Exist(m => m.UserName == userName && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
            {
                // 校验不通过
                return(Content("false"));
            }
            else
            {
                return(Content("true"));
            }
        }
Exemplo n.º 17
0
        public ApiResultModel ChangePassword(OwnerChangePasswordModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //获取要修改密码的物业用户
                IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    string OldMd5Pwd = PropertyUtils.GetMD5Str(model.OldPwd);
                    //如果输入的旧密码与数据库中不一致
                    if (OldMd5Pwd != user.Password)
                    {
                        resultModel.Msg = APIMessage.OLD_PWD_ERROR;
                    }
                    else
                    {
                        //修改密码并保存
                        user.Password = PropertyUtils.GetMD5Str(model.NewPwd);
                        userBll.Update(user);
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 18
0
        public ActionResult PropertyUserList(PropertyPlaceSearchModel model)
        {
            IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

            int propertyCompanyId = GetSessionModel().CompanyId.Value;

            Expression <Func <T_PropertyUser, bool> > where = u => (string.IsNullOrEmpty(model.Kword) ? true : (u.TrueName.Contains(model.Kword) || u.UserName.Contains(model.Kword))) && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.PropertyPlace.CompanyId == propertyCompanyId;
            if (model.PropertyPlaceId != null)
            {
                where = PredicateBuilder.And(where, u => u.PropertyPlaceId == model.PropertyPlaceId.Value);
            }
            var sortModel = this.SettingSorting("Id", false);

            model.DataUserList      = propertyUserBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex) as PagedList <T_PropertyUser>;
            model.PropertyPlaceList = GetPropertyPlaceList();
            return(View(model));
        }
Exemplo n.º 19
0
        /// <summary>
        /// 获取本小区物业用户列表
        /// </summary>
        /// <param name="currentPlaceId">物业小区ID</param>
        /// <returns>物业用户列表</returns>
        private List <SelectListItem> GetUserList(int currentPlaceId)
        {
            var sortModel = this.SettingSorting("Id", false);

            //调用BLL层获取物业用户列表
            IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

            var pointList = userBll.GetList(c => c.PropertyPlaceId == currentPlaceId &&
                                            c.DelFlag == ConstantParam.DEL_FLAG_DEFAULT, sortModel.SortName, sortModel.IsAsc).ToList();

            //转换为下拉列表并返回
            return(pointList.Select(c => new SelectListItem()
            {
                Text = string.IsNullOrEmpty(c.TrueName) ? c.UserName : (pointList.Count(p => p.TrueName == c.TrueName) > 1 ? c.TrueName + "(" + c.UserName + ")" : c.TrueName),
                Value = c.Id.ToString(),
                Selected = false,
            }).ToList());
        }
Exemplo n.º 20
0
        public ActionResult SetPropUserInfo(LoggedInAccountModel model)
        {
            JsonModel jm = new JsonModel();

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

                IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

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

                    //更新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));
        }
Exemplo n.º 21
0
        public ApiResultModel GetDisposerList([FromUri] TokenModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //获取物业用户列表
                    Expression <Func <T_PropertyUser, bool> > where = u => u.PropertyPlaceId == user.PropertyPlaceId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT;
                    var userList = userBll.GetList(where, "Id", false).ToList();

                    resultModel.result = userList.Select(u => new
                    {
                        UserId = u.Id,
                        Name   = string.IsNullOrEmpty(u.TrueName) ? u.UserName : (userList.Count(p => p.TrueName == u.TrueName) > 1 ? u.TrueName + "(" + u.UserName + ")" : u.TrueName)
                    });
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 设置管理员提交
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonModel SetAdmin(PropertyUserModel model)
        {
            JsonModel jm = new JsonModel();

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

                T_PropertyUser propertyUser = new T_PropertyUser()
                {
                    PropertyPlaceId = model.PlaceId,
                    UserName        = model.UserName,
                    Email           = model.Email,
                    Password        = PropertyUtils.GetMD5Str(model.Password),
                    IsMgr           = ConstantParam.USER_ROLE_MGR,
                    DelFlag         = ConstantParam.DEL_FLAG_DEFAULT,
                };

                //为管理员添加角色
                IPropertyRoleBLL roleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL");

                var role = roleBll.GetEntity(r => r.IsSystem == ConstantParam.USER_ROLE_MGR && r.PropertyPlaceId == model.PlaceId);
                if (role != null)
                {
                    propertyUser.PropertyUserRoles.Add(new R_PropertyUserRole()
                    {
                        RoleId = role.Id,
                    });
                }
                //创建管理员
                propertyUserBll.Save(propertyUser);

                //日志记录
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(jm);
        }
Exemplo n.º 23
0
        public ApiResultModel GetUserInfo([FromUri] TokenModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //初始化物业用户基本信息并返回
                    OwnerModel ownerM = new OwnerModel()
                    {
                        UserName = string.IsNullOrEmpty(user.TrueName) ? user.UserName : user.TrueName,
                        HeadPath = user.HeadPath,
                        Gender   = user.Gender == null ? -1 : user.Gender.Value
                    };
                    resultModel.result = ownerM;
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 24
0
        public ActionResult EditPropUserPwd()
        {
            UserSessionModel sessionModel = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO];
            var id = sessionModel.UserID;

            IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

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

            if (userInfo != null)
            {
                AccountPasswordChangeModel propertyUserModel = new AccountPasswordChangeModel();
                propertyUserModel.UserId   = userInfo.Id;
                propertyUserModel.UserName = userInfo.UserName;
                return(View(propertyUserModel));
            }
            else
            {
                return(RedirectToAction("Index", "Property"));
            }
        }
Exemplo n.º 25
0
        public ActionResult EditUser(int?id)
        {
            // 参数校验
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

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

            if (userInfo != null)
            {
                PropertyUserModel propertyUserModel = new PropertyUserModel();
                propertyUserModel.UserId   = userInfo.Id;
                propertyUserModel.UserName = userInfo.UserName;
                propertyUserModel.TrueName = userInfo.TrueName;
                propertyUserModel.Memo     = userInfo.Memo;
                propertyUserModel.Tel      = userInfo.Tel;
                propertyUserModel.Phone    = userInfo.Phone;
                propertyUserModel.Email    = userInfo.Email;
                propertyUserModel.HeadPath = userInfo.HeadPath;
                propertyUserModel.PlaceId  = GetSessionModel().PropertyPlaceId.Value;
                // 获取指定小区的名称
                IPropertyPlaceBLL propertyPlaceBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

                var place = propertyPlaceBll.GetEntity(m => m.Id == propertyUserModel.PlaceId);
                if (place != null)
                {
                    propertyUserModel.PlaceName = place.Name;
                }

                return(View(propertyUserModel));
            }
            else
            {
                return(RedirectToAction("UserList"));
            }
        }
Exemplo n.º 26
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);
        }
Exemplo n.º 27
0
        public ApiResultModel CompanyNewsDetail([FromUri] NewsDetailModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找物业用户
                IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser propertyUser = propertyUserBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果物业用户存在
                if (propertyUser != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > propertyUser.TokenInvalidTime || model.Token != propertyUser.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    propertyUser.LatelyLoginTime  = DateTime.Now;
                    propertyUser.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    propertyUserBll.Update(propertyUser);

                    // 返回详细页面url
                    resultModel.result = "MobilePage/CompanyNewsDetail?id=" + model.PostId;
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 28
0
        public ActionResult EditUser(PropertyUserModel model)
        {
            JsonModel jm = new JsonModel();

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

                T_PropertyUser propertyUser = propertyUserBll.GetEntity(m => m.Id == model.UserId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (propertyUser != null)
                {
                    propertyUser.UserName = model.UserName;
                    propertyUser.TrueName = model.TrueName;
                    propertyUser.Memo     = model.Memo;
                    propertyUser.Tel      = model.Tel;
                    propertyUser.Phone    = model.Phone;
                    propertyUser.Email    = model.Email;
                    // 保存到数据库
                    propertyUserBll.Update(propertyUser);

                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "该用户不存在";
                }
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 29
0
        public ActionResult SetPropUserInfo()
        {
            // 获取Session Model
            UserSessionModel model = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO];
            var id = model.UserID;

            IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

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

            if (userInfo != null)
            {
                LoggedInAccountModel propertyUserModel = new LoggedInAccountModel();
                propertyUserModel.UserId   = userInfo.Id;
                propertyUserModel.UserName = userInfo.UserName;
                propertyUserModel.TrueName = userInfo.TrueName;
                propertyUserModel.Memo     = userInfo.Memo;
                propertyUserModel.Tel      = userInfo.Tel;
                propertyUserModel.Phone    = userInfo.Phone;
                propertyUserModel.Email    = userInfo.Email;
                propertyUserModel.HeadPath = userInfo.HeadPath;
                propertyUserModel.PlaceId  = model.PropertyPlaceId.Value;
                // 获取指定小区的名称
                IPropertyPlaceBLL propertyPlaceBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

                var place = propertyPlaceBll.GetEntity(m => m.Id == propertyUserModel.PlaceId);
                if (place != null)
                {
                    propertyUserModel.PlaceName = place.Name;
                }
                return(View(propertyUserModel));
            }
            else
            {
                return(RedirectToAction("Index", "Property"));
            }
        }
Exemplo n.º 30
0
        public ActionResult EditPropUserPwd(AccountPasswordChangeModel model)
        {
            JsonModel jm = new JsonModel();

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

                // 若当前登录用户为物业用户
                IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser propertyUser = propertyUserBll.GetEntity(m => m.Id == model.UserId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (propertyUser != null)
                {
                    propertyUser.Password         = PropertyUtils.GetMD5Str(model.Password);
                    propertyUser.Token            = null;
                    propertyUser.TokenInvalidTime = null;
                    // 保存到数据库
                    propertyUserBll.Update(propertyUser);
                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "该用户不存在";
                }
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }