public object FaceRegistration() { try { var user = CurrentUserView; if (user == null) { throw new Exception("获取用户信息失败!"); } var http = HttpContext.Current; var form = http.Request.Form; string image = form["image"]; string source = RoleType.Supplier.ToString(); using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(user))) { var userFaceResult = proxy.AddAIUserFaceInfo(user.UserId, image, source); if (userFaceResult.Flag == EResultFlag.Success && userFaceResult.Data == 1) { return(APIResult.GetSuccessResult(MsgCode.Success, "操作成功!")); } else { return(APIResult.GetErrorResult(MsgCode.CommonError, "操作失败!")); } } } catch { return(APIResult.GetErrorResult(MsgCode.UserInfoError, "获取用户信息错误!")); } }
public object ForgetPwd(string tel, string pwd, string code) { //if (string.IsNullOrWhiteSpace(tel)) //{ // return Json(new APIResult(MsgCode.CommonError, "请输入电话号码!")); //} //if (string.IsNullOrWhiteSpace(pwd)) //{ // return Json(new APIResult(MsgCode.CommonError, "请输入新密码!")); //} //if (string.IsNullOrWhiteSpace(code)) //{ // return Json(new APIResult(MsgCode.CommonError, "请输入新密码!")); //} //if (CurrentUserView != null) //{ // if (!CurrentUserView.PassWord.Equals(pwd)) // { // return Json(new APIResult(MsgCode.CommonError, "旧密码不正确!")); // } // using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(CurrentUserId))) // { // var result = proxy.UpdatePassword(CurrentUserView.Id, pwd); // if (result.Flag == EResultFlag.Success) // { // return Json(new APIResult(MsgCode.Success, "密码修改成功!")); // } // return Json(new APIResult(MsgCode.CommonError, result.Exception.Decription)); // } //} return(Json(APIResult.GetErrorResult("获取用户信息错误!"))); }
public object ValidateToken(string token, int type) { string tempToken = ""; DateTime expiryTime = DateTime.MinValue; Result <Base_User> login = new Result <Base_User>(); using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(token))) { login = proxy.GetBaseUserByToken(token, type); if (login.Flag == 0) { var data = login.Data; tempToken = type == 1 ? data.AndroidToken : data.IosToken; //模拟用户数据库中的token expiryTime = type == 1 ? data.AndroidTokenTime.Value : data.IosTokenTime.Value; //模拟用户数据库中的token过期时间 } } //没有根据token查到用户 if (token == tempToken && DateTime.Now <= expiryTime) { return(APIResult.GetSuccessResult(new { token })); } return(APIResult.GetErrorResult(MsgCode.InvalidToken)); }
public object GetList(string signTime = "2018-05-21 08:55:00") { signTime = APIAESTool.AesEncrypt(signTime); if (!string.IsNullOrEmpty(signTime)) { var isSign = CheckSignTime(signTime); if (!isSign) { return(Json(APIResult.GetErrorResult(MsgCode.SignTimeError))); } } return(APIResult.GetSuccessResult("token验证通过,已取得数据!")); }
public object GetAuthTicket(string user, string pwd) { string tokenTicket = ""; //登录 var loginResult = login(user, pwd, Sys, out tokenTicket); if (loginResult) { var obj = new { token = tokenTicket }; return(APIResult.GetSuccessResult(obj)); } return(APIResult.GetErrorResult(MsgCode.LoginError)); }
public object UpdatePwd(UserPwd model) { if (model == null) { return(Json(APIResult.GetErrorResult("请输入旧密码!"))); } string oldpwd = model.oldpwd; string pwd = model.pwd; if (string.IsNullOrWhiteSpace(oldpwd)) { return(Json(APIResult.GetErrorResult("请输入旧密码!"))); } if (string.IsNullOrWhiteSpace(pwd)) { return(Json(APIResult.GetErrorResult("请输入新密码!"))); } if (pwd.Equals(oldpwd)) { return(Json(APIResult.GetErrorResult("新密码不能和旧密码相同!"))); } oldpwd = APIAESTool.AesDecrypt(oldpwd); oldpwd = DesTool.DesEncrypt(oldpwd); pwd = APIAESTool.AesDecrypt(pwd); pwd = DesTool.DesEncrypt(pwd); var user = CurrentUserView; if (user != null) { using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(user))) { var result = proxy.UpdatePassword(user.UserId, oldpwd, pwd); if (result.Flag == EResultFlag.Success) { return(Json(APIResult.GetSuccessResult("密码修改成功!"))); } return(Json(APIResult.GetErrorResult(MsgCode.CommonError, result.Exception.Decription))); } } return(Json(APIResult.GetErrorResult(MsgCode.InvalidToken))); }
public object FaceDistinguish() { SignFaceAI model = new SignFaceAI(); try { var user = CurrentUserView; if (user == null) { throw new Exception("获取用户信息失败!"); } var http = HttpContext.Current; var form = http.Request.Form; model.Image = form["image"]; model.ProjectId = Convert.ToInt64(form["projectId"]); model.ProjectName = form["projectName"]; model.Longitude = form["longitude"]; model.Latitude = form["latitude"]; model.OilStationName = form["oilStationName"]; model.UserId = user.UserId; using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(user))) { var userFaceResult = proxy.SearchUserFace(model); if (userFaceResult.Flag == EResultFlag.Success && userFaceResult.Data == 1) { return(APIResult.GetSuccessResult(MsgCode.Success, "操作成功!")); } else { string msg = "人脸不匹配!"; if (userFaceResult.Exception != null) { msg = userFaceResult.Exception.Decription; } return(APIResult.GetErrorResult(MsgCode.CommonError, msg)); } } } catch { return(APIResult.GetErrorResult(MsgCode.UserInfoError, "获取用户信息错误!")); } }
public object GetUser() { try { var user = CurrentUserView; if (user == null) { throw new Exception("获取用户信息失败!"); } Dictionary <long, string> userPhoto = null; bool userFace = false; using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(""))) { userPhoto = AppCommonHelper.GetUserProfilePhotoList(proxy, new List <long>() { user.UserId }); var userFaceResult = proxy.GetAIUserFace(user.UserId); if (userFaceResult.Flag == EResultFlag.Success && userFaceResult.Data != null) { userFace = true; } } var data = new { userId = user.UserId, userName = user.RealName, img = AppCommonHelper.GetUserProfilePhoto(user.UserId, userPhoto, user), phone = user.Phone, companyName = user.CompanyName, qq = user.Qq, weChat = user.WeChat, mail = user.Email, isFace = userFace }; return(APIResult.GetSuccessResult(data)); } catch { return(APIResult.GetErrorResult(MsgCode.UserInfoError, "获取用户信息错误!")); } }
public object GetAppVersion() { string appNum = AppNum; if (string.IsNullOrWhiteSpace(appNum)) { return(APIResult.GetErrorResult("获取更新版本失败!")); } using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(""))) { var result = proxy.GetAppVersion(appNum); if (result.Flag == EResultFlag.Failure) { return(APIResult.GetErrorResult(result.Exception)); } if (result.Data == null) { return(APIResult.GetSuccessNoData()); } var data = new { appNum = result.Data.AppNum, //包名 versionCode = result.Data.VersionCode, //版本号 version = result.Data.VersionSn, //版本名称 url = result.Data.Url, //版本下载路径 isForced = result.Data.IsForced, //是否强更:1-强制更新、2-普通更新 log = result.Data.UpdateLog //版本更新说明 }; return(APIResult.GetSuccessResult(data)); } }
public object NewAddMonitor(long projectId) { //判断项目ID是否为空 if (projectId <= 0) { return(APIResult.GetErrorResult("请选择所属项目!")); } #region 整合变量定义 var user = CurrentUserView; //角色权限定义 string roleType = string.Empty; //监理ID类型 long jlUserId = 0; #endregion //获取实体数据表结构checkItemList List <Epm_CheckItem> checkItemList = new List <Epm_CheckItem>(); List <Epm_InspectItem> itemDraftList = new List <Epm_InspectItem>(); using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(user))) { #region RoleType(角色权限控制) bool isAgency = proxy.IsAgencyUser(user.UserId); if (!isAgency) { bool isBranch = proxy.IsBranchCompanyUser(user.UserId); if (!isBranch) { bool isSupervisor = proxy.IsSupervisor(projectId, user.UserId); if (isSupervisor) { roleType = RoleTypeEnum.JL.ToString(); } else { roleType = RoleTypeEnum.ZJL.ToString(); } } else { roleType = RoleTypeEnum.FGS.ToString(); var getProjectCompanyResult = proxy.GetProjectCompanyByProjectId(projectId); if (getProjectCompanyResult.Flag == EResultFlag.Success && getProjectCompanyResult.Data != null) { var company = getProjectCompanyResult.Data.FirstOrDefault(t => t.IsSupervisor == 1); if (company != null) { jlUserId = company.LinkManId.Value; } } } } else { roleType = RoleTypeEnum.SGS.ToString(); } #endregion } //获取所有检查项目内容级节点 checkItemList = proxy.GetCheckItemAll().Data; itemDraftList = proxy.GetInspectItemDraft(projectId).Data; Epm_Project project = proxy.GetProject(projectId).Data; var distinctcheckItem = checkItemList.Where(t => t.RoleType == roleType && t.Level == 3).Select(a => new { a.ScoreCompany, }).Distinct().ToList(); var data = new { address = project.Name, date = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"), checkItems = checkItemList.OrderBy(t => t.Sort).Where(t => t.RoleType == roleType && t.Level == 1).Select(a => new { id = a.Id, name = a.Name, level = 1, selected = false, }), questionType = GetListQue(checkItemList, roleType), //整改单位 companies = GetListCom(checkItemList, roleType, projectId), //整改人 //rectification = GetListPer(checkItemList, roleType), //分值 score = checkItemList.OrderBy(t => t.Sort).Where(t => t.RoleType == roleType && t.Level == 3).FirstOrDefault().ScoreRange.Split(','), }; return(APIResult.GetSuccessResult(data)); } }
public object GetUserMenu(long projectId) { try { if (projectId <= 0) { return(APIResult.GetSuccessNoDatas()); } var user = CurrentUserView; if (user != null) { var list = Enum <BusinessType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).Select(p => new { code = p.Key }).ToList(); if (user.CompanyType.Equals(RoleType.Owner.ToString())) { list = list.Where(p => p.code == BusinessType.SecurityCheck.ToString() || p.code == BusinessType.Question.ToString()).ToList(); } if (user.CompanyType.Equals(RoleType.Supplier.ToString())) { using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(user))) { if (proxy.IsSupervisor(projectId, user.UserId)) { list = list.Where(p => p.code == BusinessType.Log.ToString() || p.code == BusinessType.Equipment.ToString() || p.code == BusinessType.Visa.ToString() || p.code == BusinessType.Question.ToString() || p.code == BusinessType.SecurityCheck.ToString() || //返回监理现场检查类型; p.code == BusinessType.Rectification.ToString() || //发起整改单 p.code == BusinessType.Dangerous.ToString()).ToList(); } else { list = list.Where(p => p.code == BusinessType.Track.ToString() || p.code == BusinessType.DelayApply.ToString() || p.code == BusinessType.Question.ToString()).ToList(); //list.Add(new //{ // code = SystemRight.UploadSecurityCheck.ToString() //}); list.Add(new { code = SystemRight.UploadWork.ToString() }); } } } list.Add(new { code = SystemRight.UploadSecurityCheck.ToString() }); list.Add(new { code = SystemRight.FaceAI.ToString() }); return(APIResult.GetSuccessResult(list)); } return(APIResult.GetErrorResult(MsgCode.InvalidToken)); } catch (Exception ex) { return(APIResult.GetErrorResult(ex.Message)); } finally { } }