/// <summary> /// 获取用户机构列表 /// </summary> /// <param name="ManagementNo"></param> /// <returns></returns> public UserOrgAssignVo GetUserOrgAssign(long UserNo) { UserOrgAssignVo assignVo = new UserOrgAssignVo(); List <PsUserOrg> userOrgs = this.GetUserOrgs(UserNo); UcUsers users = DataHandleManager.Instance().UcUsersHandle.GetUsersInfo(UserNo.ToString()); assignVo.userName = users == null ? "" : users.UserName; assignVo.userNo = users == null ? -1 : long.Parse(users.UserNo); assignVo.UsersSettingInfo = DataHandleManager.Instance().UcUsersSettingHandle.GetUcUsersSettingInfo(UserNo.ToString()); long PlatformNo = assignVo.UsersSettingInfo == null ? ConstData.DefaultNo : assignVo.UsersSettingInfo.PlatformNo; List <OptionValue> optionValues = DataHandleManager.Instance().PsOrganizationHandle.GetOptionValues(new List <long>() { PlatformNo }); assignVo.optionValues = new List <CheckOptionValue>(); foreach (var item in optionValues) { bool isCheck = userOrgs.Where(o => o.OrgNo == item.Value).FirstOrDefault() != null; assignVo.optionValues.Add(new CheckOptionValue() { isCheck = isCheck, Name = item.Name, Value = item.Value }); } return(assignVo); }
public JsonResult Login(string UserName, string Password, string Captcha) { LoginInfoForm loginInfoForm = new LoginInfoForm(); loginInfoForm.UserName = UserName; loginInfoForm.Password = Password; loginInfoForm.LoginerInfo = "123"; loginInfoForm.Platform = AppBusiness.PlatformCode; JsonResponses responses = loginSdk.Login(loginInfoForm); if (responses.code == JsonResponses.Success.code) { UcUsers users = JsonConvert.DeserializeObject <UcUsers>(responses.data.ToString()); UcUsersSetting usersSetting = userSettingSdk.GetUserSettingInfo(users.UserNo); if (usersSetting != null) { string APPKey = usersSetting.AppSecret; LoginModel.Instance().UserNo = users.UserNo; LoginModel.Instance().Token = MD5Helper.GetMD5String(users.UserNo + APPKey + DateTime.Now.ToString("yyyyMMddHHmmss"));; LoginModel.Instance().ManagementValue = 1213; // roles.ManagementValue; LoginModel.Instance().UserRolesName = "123"; // roles.Name; LoginModel.Instance().UserRule = "123"; //DataHandleManager.Instance().UsersRuleHandle.GetUserRoles(UserNo); LoginModel.Instance().PlatformNo = usersSetting.PlatformNo; AppBusiness.loginModel = LoginModel.Instance(); } else { responses.code = JsonResponses.FailedCode; responses.msg = "用户信息缺失"; } } return(Json(responses, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 平台注册用户 /// </summary> /// <param name="registerPlatform"></param> /// <returns></returns> public LoginResultType RegisterPlatform(RegisterPlatformForm registerPlatform) { try { if (CheckUserNoIsExist(registerPlatform.UserNo)) { return(LoginResultType.ERROR_USER_NOT_EXIST); } if (CheckEmailIsExist(registerPlatform.Email)) { return(LoginResultType.ERROR_EMAIL_NOT_EXIST); } if (CheckPhoneIsExist(registerPlatform.Phone)) { return(LoginResultType.ERROR_PHONE_NOT_EXIST); } string UserNo = registerPlatform.UserNo; if (UserNo.Equals(ConstData.DefaultNo)) { UserNo = AutoIDWorker.Example.GetAutoSequence().ToString(); } UcUsers users = new UcUsers() { UserNo = UserNo, UserName = registerPlatform.UserName, Password = registerPlatform.Password, Phone = registerPlatform.Phone, Email = registerPlatform.Email, InputUser = registerPlatform.InputUser, InputTime = DateTime.Now, Enabled = 1, }; UcUsersSetting usersSetting = new UcUsersSetting() { UserNo = UserNo, AppId = RandomUtils.NextInt(100000, 999999).ToString(), AppSecret = RandomUtils.NextInt(100000, 999999).ToString(), PlatformNo = registerPlatform.PlatformNo, Enabled = 1, InputUser = registerPlatform.InputUser, InputTime = DateTime.Now, ManagementId = 1, ManagementValue = 1 }; int result = DataHandleManager.Instance().UcUsersHandle.Insert(users); if (result > 0) { result = DataHandleManager.Instance().UcUsersSettingHandle.Insert(usersSetting); registerPlatform.UserNo = UserNo; return(LoginResultType.SUCCESS_REGISTOR); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(LoginResultType.FAILED_REGISTOR); }
/// <summary> /// 平台登录业务 /// </summary> /// <param name="loginForm"></param> /// <returns></returns> public LoginResultType PlatformLogin(LoginInfoForm loginForm, ref UcUsers info) { LoginResultType loginResultType = this.Login(loginForm.UserName, loginForm.MdfPas, loginForm.LoginerInfo, loginForm.Password, ref info); if (loginResultType == LoginResultType.SUCCESS_LOGIN) { loginForm.UserNo = info.UserNo; } bool result = DataHandleManager.Instance().UcLoginLogHandle.InsertLoginLog(loginForm, loginResultType); return(loginResultType); }
public ActionResult <JsonResponses> LoginGet([FromQuery] LoginInfoForm loginInfoForm) { string MdfPas = MD5Helper.GetMD5String(loginInfoForm.Password); UcUsers users = new UcUsers(); LoginResultType LoginResult = DataHandleManager.Instance().UcUsersHandle.Login(loginInfoForm.UserName, MdfPas, loginInfoForm.LoginerInfo, loginInfoForm.Platform, ref users); if (LoginResult == LoginResultType.SUCCESS_LOGIN) { return(new JsonResponses(JsonResponses.Success.code, LoginResult.ToString(), LoginResult)); } return(new JsonResponses(JsonResponses.Failed.code, LoginResult.ToString(), LoginResult)); }
public ActionResult <JsonResponses> Login([FromForm] LoginInfoForm loginInfoForm) { loginInfoForm.MdfPas = MD5Helper.GetMD5String(loginInfoForm.Password); UcUsers users = new UcUsers(); LoginResultType LoginResult = DataHandleManager.Instance().UcUsersHandle.PlatformLogin(loginInfoForm, ref users); if (LoginResult == LoginResultType.SUCCESS_LOGIN) { this.LoginAfterSuccess(users); return(new JsonResponses(JsonResponses.Success.code, LoginResult.ToString(), users)); } return(new JsonResponses(JsonResponses.Failed.code, LoginResult.ToString(), LoginResult)); }
public ActionResult <JsonResponses> GetUserInfo([FromQuery] string userNo) { try { UcUsers users = DataHandleManager.Instance().UcUsersHandle.GetUsersInfo(userNo); return(new JsonResponses(users)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(JsonResponses.Failed); }
/// <summary> /// 登录成功后 /// </summary> /// <param name="users"></param> private void LoginAfterSuccess(UcUsers users) { string userNo = users.UserNo; UcUsersSetting usersSetting = DataHandleManager.Instance().UcUsersSettingHandle.GetUcUsersSettingInfo(userNo); if (usersSetting == null) { return; } OperatorVo operatorVo = new OperatorVo() { userNo = userNo, platformNo = usersSetting.PlatformNo }; HttpContext.Session.Set(AuthorizeFilterAttribute.LoginSessionKey, operatorVo); }
public JsonResult UcUsersAdd(UcUsers model) { model.InputUser = AppBusiness.loginModel.UserNo; RegisterPlatformForm registerPlatform = new RegisterPlatformForm() { UserName = model.UserName, UserNo = model.UserNo, InputUser = model.InputUser, Email = model.Email, Phone = model.Phone, Password = "******", PlatformNo = AppBusiness.loginModel.PlatformNo }; JsonResponses jsonResponses = userSDK.RegisterPlatfrom(registerPlatform); return(Json(jsonResponses, JsonRequestBehavior.AllowGet)); }
public ActionResult <JsonResponses> Create([FromForm] PsPlatform platform) { try { //bool checkResult = true; platform.InputTime = DateTime.Now; platform.PlatformNo = AutoIDWorker.Example.GetAutoSequence(); PsPlatform ParentInfo = DataHandleManager.Instance().PsPlatformHandle.GetModelByKey(platform.ParentNo.ToString()); platform.TreeLevelNo = TreeLevelUtil.GetTreeLevelNo <PsPlatform>(ParentInfo, platform.ParentNo); UcUsers users = this.userSDK.GetUserInfo(Convert.ToInt32(platform.DefaultUserNo)); if (users != null) { return(new JsonResponses("用户已存在")); } RegisterPlatformForm registerPlatformForm = new RegisterPlatformForm(); registerPlatformForm.UserNo = platform.DefaultUserNo; registerPlatformForm.UserName = platform.DefaultUserName; registerPlatformForm.PlatformNo = platform.PlatformNo; registerPlatformForm.Password = ConstData.DEFAULT_PASSWORD; registerPlatformForm.Phone = ""; registerPlatformForm.Email = ""; registerPlatformForm.InputUser = platform.InputUser; JsonResponses jsonResponses = userSDK.RegisterPlatfrom(registerPlatformForm); if (!jsonResponses.ValidateResponses()) { return(jsonResponses); } int result = DataHandleManager.Instance().PsPlatformHandle.Insert(platform); if (result > 0) { return(JsonResponses.Success); } return(JsonResponses.Failed); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(JsonResponses.Failed); }
/// <summary> /// 获取用户角色信息 /// </summary> /// <param name="usersNo"></param> /// <returns></returns> public RolesAssignVo GetRolesAssign(long UsersNo) { RolesAssignVo assignVo = new RolesAssignVo(); List <PsUserRoles> psUserRoles = this.GetUserRoles(UsersNo); UcUsers users = DataHandleManager.Instance().UcUsersHandle.GetUsersInfo(UsersNo.ToString()); assignVo.UserName = users == null ? "" : users.UserName; assignVo.UsersSettingInfo = DataHandleManager.Instance().UcUsersSettingHandle.GetUcUsersSettingInfo(UsersNo.ToString()); long PlatformNo = assignVo.UsersSettingInfo == null ?ConstData.DefaultNo : assignVo.UsersSettingInfo.PlatformNo; List <OptionValue> optionValues = DataHandleManager.Instance().PsRolesHandle.GetOptionValues(PlatformNo); assignVo.optionValues = new List <CheckOptionValue>(); foreach (var item in optionValues) { bool isCheck = psUserRoles.Where(o => o.RolesNo == item.Value).FirstOrDefault() != null; assignVo.optionValues.Add(new CheckOptionValue() { isCheck = isCheck, Name = item.Name, Value = item.Value }); } return(assignVo); }
/// <summary> /// 登陆业务 /// </summary> /// <param name="UserName">用户名</param> /// <param name="Md5Pas">密码</param> /// <param name="LoginerInfo">登陆者信息</param> /// <param name="platform">平台code</param> /// <param name="info"></param> /// <returns></returns> public LoginResultType Login(string UserName, string Md5Pas, string LoginerInfo, string platform, ref UcUsers info) { if (UserName == "" || Md5Pas == "" || UserName == null || Md5Pas == null) { return(LoginResultType.ERROR_PARA); //账号或者密码为空 } Expression <Func <UcUsers, bool> > la = (n => n.Phone == UserName || n.Email == UserName || n.UserName == UserName || n.UserNo == UserName); info = this.Get(la); if (info == null || string.IsNullOrEmpty(info.UserNo)) { return(LoginResultType.ERROR_USER_NOT_EXIST);//登录账号不存在 } if (info.Enabled == 0) { return(LoginResultType.ERROR_USER_INACTIVE);//账号停用 } if (info.FailedLoginCount >= 3 && info.FailedLoginTime.AddMinutes(15).CompareTo(DateTime.Now) > 0) { return(LoginResultType.ERROR_PASSWORD_TOO_MUCH);//密码输入错误次数超过三次 } string UserNo = info.UserNo; if (Md5Pas != info.Password) { this.UpdateFailLogin(UserNo, false, LoginerInfo); //更新错误登录次数 return(LoginResultType.ERROR_PASSWORD); //密码错误 } this.UpdateFailLogin(UserNo, true, LoginerInfo); //清零错误登录次数 return(LoginResultType.SUCCESS_LOGIN); }