コード例 #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));
        }
コード例 #2
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));
        }
コード例 #3
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));
        }
コード例 #4
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);
        }
コード例 #5
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"));
        }
コード例 #6
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);
        }
コード例 #7
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));
        }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
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);
        }
コード例 #11
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);
        }
コード例 #12
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);
        }
コード例 #13
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);
        }
コード例 #14
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));
        }
コード例 #15
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);
        }
コード例 #16
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"));
            }
        }
コード例 #17
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"));
            }
        }
コード例 #18
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);
        }
コード例 #19
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);
        }
コード例 #20
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));
        }
コード例 #21
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"));
            }
        }
コード例 #22
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));
        }
コード例 #23
0
        public ActionResult UploadPic(int id)
        {
            JsonModel        jm      = new JsonModel();
            IPropertyUserBLL UserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

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

            //用户存在
            if (user != null)
            {
                PropertyUserModel userModel = new PropertyUserModel()
                {
                    UserId   = user.Id,
                    HeadPath = user.HeadPath
                };
                return(View(userModel));
            }
            //用户不存在
            else
            {
                jm.Msg = "用户不存在";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
コード例 #24
0
        public ActionResult ConfigRole(PropertyUserConfigRoleModel model)
        {
            JsonModel jm = new JsonModel();

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

            //获取要分配角色的物业用户
            T_PropertyUser user = propertyUserBll.GetEntity(m => m.Id == model.userId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

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

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

            //修改物业用户对应的角色集合
            if (propertyUserBll.ConfigRole(user, roles))
            {
                jm.Content = "物业用户 " + user.TrueName + " 分配角色";
            }
            else
            {
                jm.Msg = "分配角色失败";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
コード例 #25
0
        public ActionResult ConfigRole(int id)
        {
            // 创建物业用户角色模型
            PropertyUserRoleModel userRoleModel = new PropertyUserRoleModel();

            // 获取指定id的物业用户模型
            IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

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

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

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

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

            userRoleModel.RoleList = roleList;

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

            return(View(userRoleModel));
        }
コード例 #26
0
        public ApiResultModel Login(OwnerLoginModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

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

                T_PropertyUser user = propertyUserBll.GetEntity(u => u.UserName == model.UserName &&
                                                                u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                //1.判断用户名是否正确
                if (user == null)
                {
                    resultModel.Msg = APIMessage.NAME_ERROR;
                    return(resultModel);
                }

                //2.判断密码是否正确
                string md5Str = PropertyUtils.GetMD5Str(model.Password);
                if (user.Password != md5Str)
                {
                    resultModel.Msg = APIMessage.PWD_ERROR;
                    return(resultModel);
                }

                //产生随机令牌
                var token = System.Guid.NewGuid().ToString("N");
                //更新用户令牌和最近登录时间及Token失效时间
                user.Token            = token;
                user.LatelyLoginTime  = DateTime.Now;
                user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                propertyUserBll.Update(user);

                //返回登录用户的ID和用户名以及令牌
                resultModel.result = new { token = token, userId = user.Id, userName = user.UserName, isMgr = user.IsMgr };

                //推送设备管理
                IPropertyUserPushBLL userPushBll = BLLFactory <IPropertyUserPushBLL> .GetBLL("PropertyUserPushBLL");

                var userPush  = userPushBll.GetEntity(p => p.UserId == user.Id);
                var userPush1 = userPushBll.GetEntity(p => p.RegistrationId == model.RegistrationId);
                if (userPush != null)
                {
                    userPush.RegistrationId = model.RegistrationId;
                    userPushBll.Update(userPush);
                }
                else if (userPush1 != null)
                {
                    userPush1.UserId = user.Id;
                    userPushBll.Update(userPush1);
                }
                else
                {
                    userPush = new T_PropertyUserPush()
                    {
                        UserId         = user.Id,
                        RegistrationId = model.RegistrationId
                    };
                    userPushBll.Save(userPush);
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
コード例 #27
0
        public ApiResultModel SetUserInfo(OwnerInfoModel 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")));

                    //设定头像路径及文件名
                    string dir = HttpContext.Current.Server.MapPath(ConstantParam.PROPERTY_USER_HEAD_DIR);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    //设置头像
                    if (!string.IsNullOrEmpty(model.HeadPic))
                    {
                        var    fileName = DateTime.Now.ToFileTime().ToString() + ".jpg";
                        string filepath = Path.Combine(dir, fileName);

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

                        //删除旧头像
                        if (!string.IsNullOrEmpty(user.HeadPath))
                        {
                            FileInfo f = new FileInfo(HttpContext.Current.Server.MapPath(user.HeadPath));
                            if (f.Exists)
                            {
                                f.Delete();
                            }
                        }

                        //头像路径保存
                        user.HeadPath = ConstantParam.PROPERTY_USER_HEAD_DIR + "/" + fileName;
                    }
                    user.Gender = model.Gender;
                    userBll.Update(user);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
コード例 #28
0
        public ApiResultModel UploadResult(InspectionResultModel 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);

                    IInspectionTimePlanBLL planTimeBll = BLLFactory <IInspectionTimePlanBLL> .GetBLL("InspectionTimePlanBLL");

                    if (!planTimeBll.Exist(p => p.Id == model.TimePlanId))
                    {
                        resultModel.result = "该巡检安排已不存在";
                        return(resultModel);
                    }
                    IInspectionResultBLL resultBll = BLLFactory <IInspectionResultBLL> .GetBLL("InspectionResultBLL");

                    //单条巡检结果初始化
                    T_InspectionResult result = new T_InspectionResult()
                    {
                        TimePlanId   = model.TimePlanId,
                        PointId      = model.PointId,
                        Status       = model.Status,
                        Desc         = model.Desc,
                        UploadUserId = model.UserId,
                        DelFlag      = ConstantParam.DEL_FLAG_DEFAULT,
                        Longitude    = model.Longitude,
                        Latitude     = model.Latitude
                    };
                    //如果状态为异常,则设置处理状态为未处理
                    if (model.Status == ConstantParam.EXCEPTION)
                    {
                        result.DisposeStatus = ConstantParam.NO_DISPOSE;
                    }
                    //巡检异常文件资源保存目录
                    string dir = HttpContext.Current.Server.MapPath(ConstantParam.QUESTION_FILE + user.PropertyPlaceId);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //问题图片上传
                    if (!string.IsNullOrEmpty(model.ImgFiles))
                    {
                        var    fileName = DateTime.Now.ToFileTime().ToString() + ".zip";
                        string filepath = Path.Combine(dir, fileName);

                        using (FileStream fs = new FileStream(filepath, FileMode.Create))
                        {
                            using (BinaryWriter bw = new BinaryWriter(fs))
                            {
                                byte[] datas = Convert.FromBase64String(model.ImgFiles);
                                bw.Write(datas);
                                bw.Close();
                            }
                        }
                        //图片集路径保存
                        result.Imgs = PropertyUtils.UnZip(filepath, dir, ConstantParam.QUESTION_FILE + user.PropertyPlaceId);
                    }

                    //语音文件上传
                    if (!string.IsNullOrEmpty(model.AudioFile))
                    {
                        var    fileName = DateTime.Now.ToFileTime().ToString() + ".amr";
                        string filepath = Path.Combine(dir, fileName);

                        using (FileStream fs = new FileStream(filepath, FileMode.Create))
                        {
                            using (BinaryWriter bw = new BinaryWriter(fs))
                            {
                                byte[] datas = Convert.FromBase64String(model.AudioFile);
                                bw.Write(datas);
                                bw.Close();
                            }
                        }
                        //语音路径保存
                        result.AudioPath = ConstantParam.QUESTION_FILE + user.PropertyPlaceId + "/" + fileName;
                    }

                    result.ClientSaveTime = model.ClientSaveTime;
                    result.PlanDate       = model.PlanDate;
                    result.UploadTime     = DateTime.Now;

                    //上传巡检结果
                    resultBll.Save(result);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
コード例 #29
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);
        }
コード例 #30
0
        public ApiResultModel InspectionPlans([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);

                    //获取包含当日的巡检时间安排
                    IInspectionTimePlanBLL planTimeBll = BLLFactory <IInspectionTimePlanBLL> .GetBLL("InspectionTimePlanBLL");

                    //查询条件
                    Expression <Func <T_InspectionTimePlan, bool> > where = p => p.InspectionPlan.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && p.InspectionPlan.PublishedFlag == ConstantParam.PUBLISHED_TRUE &&
                                                                            p.InspectionPlan.PropertyPlaceId == user.PropertyPlaceId && p.InspectionPlan.BeginDate <= DateTime.Today && p.InspectionPlan.EndDate >= DateTime.Today;

                    where = PredicateBuilder.And(where, p => p.InspectionPlan.Type == ConstantParam.INSPECTION_TYPE_DAY ||
                                                 (p.InspectionPlan.Type == ConstantParam.INSPECTION_TYPE_WEEK && p.BeginNum == (int)DateTime.Today.DayOfWeek) ||
                                                 (p.InspectionPlan.Type == ConstantParam.INSPECTION_TYPE_MONTH && p.BeginNum == DateTime.Today.Day) ||
                                                 p.InspectionPlan.IsRandom == ConstantParam.DELIVERY_FLAG_TRUE);

                    //获取当前可以巡检的任务列表
                    var planTimeList = planTimeBll.GetList(where).ToList();
                    resultModel.result = planTimeList.Select(pt => new
                    {
                        PlanId     = pt.PlanId,
                        PlanName   = pt.InspectionPlan.PlanName,
                        Type       = pt.InspectionPlan.Type,
                        IsRandom   = pt.InspectionPlan.IsRandom,
                        Number     = pt.Number,
                        PlanTimeId = pt.Id,
                        PlanDate   = DateTime.Today.ToString("yyyy-MM-dd"),
                        TimeSpan   = pt.InspectionPlan.IsRandom == ConstantParam.DELIVERY_FLAG_TRUE ? "随机" : (pt.InspectionPlan.Type == ConstantParam.INSPECTION_TYPE_DAY ? pt.BeginNum + ":00 - " + pt.EndNum + ":00"
                            : "本日"),
                        PointList = pt.InspectionPlan.PlanPoints.Select(p => new
                        {
                            PointId        = p.PointId,
                            PointName      = p.InspectionPoint.PointName,
                            Memo           = p.InspectionPoint.Memo,
                            IsInspectioned = IsInspectioned(pt, p.PointId)
                        })
                    });
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }